Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

feat(ui): polish participant overview and theater layout (#336)

AAA6d55b4752e27
diff --git a/src/client/components/living/Couch.tsx b/src/client/components/living/Couch.tsx
index eaafaad2..2b5ff77d 100644
--- a/src/client/components/living/Couch.tsx
+++ b/src/client/components/living/Couch.tsx
@@ -7,10 +7,8 @@ const PAWN_COLORS = [
"var(--pawn-1)", "var(--pawn-2)", "var(--pawn-3)", "var(--pawn-4)",
"var(--pawn-5)", "var(--pawn-6)", "var(--pawn-7)", "var(--pawn-8)",
];
-const YOU_COLOR = "var(--you)";
-export function pawnColor(key: string, you = false): string {
- if (you) return YOU_COLOR;
+export function pawnColor(key: string): string {
let hash = 0;
for (const char of key) hash = (hash * 31 + char.charCodeAt(0)) | 0;
return PAWN_COLORS[Math.abs(hash) % PAWN_COLORS.length]!;
@@ -39,7 +37,6 @@ export interface CouchEntry {
connected: boolean;
statusLabel?: string;
you?: boolean;
- child?: boolean;
selectable?: boolean;
}
@@ -83,14 +80,12 @@ export function Couch({
: `${entry.name} · ${stateLabel}`;
const inner = (
<>
- <PawnSvg color={pawnColor(entry.key, entry.you)} />
+ <PawnSvg color={pawnColor(entry.key)} />
<i
className={`lr-pawn-led${entry.connected ? "" : " is-wait"}`}
aria-hidden="true"
/>
- <span
- className={`lr-pawn-name${entry.child ? " is-mini" : ""}`}
- >
+ <span className="lr-pawn-name">
{entry.name}
</span>
</>
@@ -99,7 +94,7 @@ export function Couch({
const style = {
animationDelay: `${Math.min(index, 12) * 70}ms`,
};
- const className = `lr-pawn${entry.you ? " is-you" : ""}${entry.child ? " is-child" : ""}${
+ const className = `lr-pawn${entry.you ? " is-you" : ""}${
entry.selectable === false ? " is-static" : ""
}${selectedKey === entry.key ? " is-selected" : ""}`;
if (entry.selectable === false) {
diff --git a/src/client/components/living/PawnDetail.tsx b/src/client/components/living/PawnDetail.tsx
index b88f7553..1e26c94c 100644
--- a/src/client/components/living/PawnDetail.tsx
+++ b/src/client/components/living/PawnDetail.tsx
@@ -1,6 +1,6 @@
// Per-viewer drill-down: name, route glyph, primary metrics, expandable
-// detailed metrics. Host sees every viewer; a viewer sees itself and its
-// relay children (matching what the wire actually delivers).
+// detailed metrics. Host sees every Viewer; a Viewer uses this only for relay
+// children because its own route already has the canonical details panel.
import { PawnSvg, pawnColor } from "./Couch";
import { Glyph } from "../../ui/icons";
import { ComicTooltip } from "./ComicTooltip";
@@ -46,7 +46,6 @@ export function RouteGlyph({ route }: { route: "p2p" | "sfu" }) {
export function PawnDetail({
pawnKey,
name,
- you = false,
route,
metrics,
direction,
@@ -58,7 +57,6 @@ export function PawnDetail({
}: {
pawnKey: string;
name: string;
- you?: boolean;
route: "p2p" | "sfu" | null;
metrics?: ConnectionMetrics | null;
direction: "send" | "receive";
@@ -72,7 +70,7 @@ export function PawnDetail({
return (
<div className="lr-row is-sub lr-pawn-detail" role="group" aria-label={name}>
<span className="lr-pawn-mini">
- <PawnSvg color={pawnColor(pawnKey, you)} />
+ <PawnSvg color={pawnColor(pawnKey)} />
</span>
{vis ? (
<span className="visually-hidden">{name}</span>
diff --git a/src/client/components/living/RouteTree.tsx b/src/client/components/living/RouteTree.tsx
index e037dcae..59b5d0a6 100644
--- a/src/client/components/living/RouteTree.tsx
+++ b/src/client/components/living/RouteTree.tsx
@@ -91,17 +91,27 @@ export const RouteTree = memo(function RouteTree({
viewers,
selfPeerId,
selectedPeerId,
+ selectablePeerIds,
+ onSelectPeer,
}: {
hostPeerId: string | null;
hostLabel: string;
viewers: readonly LabeledViewerPresence[];
selfPeerId?: string | null;
selectedPeerId?: string | null;
+ selectablePeerIds?: readonly string[];
+ onSelectPeer?: (peerId: string) => void;
}) {
const { t } = useCopy();
const narrowViewport = useNarrowViewport();
const layoutConfig = topologyLayoutForViewport(narrowViewport);
const topology = deriveParticipantTopology(hostPeerId, viewers);
+ const selectable = new Set(
+ selectablePeerIds ?? (onSelectPeer ? viewers.map((viewer) => viewer.peerId) : []),
+ );
+ const selectPeer = (peerId: string): void => {
+ if (selectable.has(peerId)) onSelectPeer?.(peerId);
+ };
const nodes: TreeNode[] = [];
const collect = (branch: TopologyBranch, via: string | null, sfu: boolean) => {
@@ -245,8 +255,9 @@ export const RouteTree = memo(function RouteTree({
</span>
<svg
viewBox={`0 0 ${width} ${height}`}
- aria-hidden="true"
- focusable="false"
+ aria-hidden={onSelectPeer ? undefined : true}
+ aria-label={onSelectPeer ? t("host.topology") : undefined}
+ focusable={onSelectPeer ? undefined : "false"}
style={
narrowViewport || scrollableCanvas
? { width, maxWidth: "none" }
@@ -360,7 +371,7 @@ export const RouteTree = memo(function RouteTree({
className={`lr-route-node${node.ready ? "" : " is-recovering"}${selected ? " is-selected" : ""}`}
transform={`translate(${centeredPawnX(point.x, scale)}, ${point.y - 15}) scale(${scale})`}
>
- <PawnSvg color={pawnColor(node.key, node.you)} />
+ <PawnSvg color={pawnColor(node.key)} />
{selected ? (
<circle className="lr-route-selection" cx="20" cy="26" r="25" />
) : null}
@@ -378,10 +389,7 @@ export const RouteTree = memo(function RouteTree({
transform={`translate(${centeredPawnX(point.x, ROOT_SCALE)}, ${point.y - 15}) scale(${ROOT_SCALE})`}
>
<PawnSvg
- color={pawnColor(
- point.viewer.peerId,
- selfPeerId === point.viewer.peerId,
- )}
+ color={pawnColor(point.viewer.peerId)}
/>
{selectedPeerId === point.viewer.peerId ? (
<circle className="lr-route-selection" cx="20" cy="26" r="25" />
@@ -427,6 +435,38 @@ export const RouteTree = memo(function RouteTree({
)}
</text>
))}
+ {[...nodes, ...pendingPos.map(({ viewer }) => ({
+ key: viewer.peerId,
+ label: viewer.label,
+ }))]
+ .filter((node) => selectable.has(node.key))
+ .map((node) => {
+ const point = pos.get(node.key) ?? pendingPos.find(
+ (pending) => pending.viewer.peerId === node.key,
+ );
+ if (!point) return null;
+ return (
+ <rect
+ key={`hit-${node.key}`}
+ className="lr-route-hit"
+ x={point.x - 48}
+ y={point.y - 28}
+ width={96}
+ height={72}
+ rx={12}
+ role="button"
+ tabIndex={0}
+ aria-label={`${node.label} · ${t("host.details")}`}
+ onClick={() => selectPeer(node.key)}
+ onKeyDown={(event) => {
+ if (event.key === "Enter" || event.key === " ") {
+ event.preventDefault();
+ selectPeer(node.key);
+ }
+ }}
+ />
+ );
+ })}
</svg>
<ul className="visually-hidden">
diff --git a/src/client/components/living/ViewerOverview.tsx b/src/client/components/living/ViewerOverview.tsx
new file mode 100644
index 00000000..66b5cc49
--- /dev/null
+++ b/src/client/components/living/ViewerOverview.tsx
@@ -0,0 +1,119 @@
+import type { ConnectionMetrics } from "../../types";
+import { formatPacketLossPercent } from "../connection-details";
+import { Glyph, type GlyphName } from "../../ui/icons";
+import { useCopy, type CopyKey } from "../../ui/copy";
+import { PawnSvg, pawnColor } from "./Couch";
+
+export interface ViewerOverviewEntry {
+ key: string;
+ name: string;
+ connected: boolean;
+ statusLabel: string;
+ route: "p2p" | "sfu" | null;
+ metrics: ConnectionMetrics | null;
+}
+
+function finite(value: number | null): value is number {
+ return value !== null && Number.isFinite(value);
+}
+
+export function ViewerOverview({
+ entries,
+ selectedKey,
+ onSelect,
+}: {
+ entries: readonly ViewerOverviewEntry[];
+ selectedKey: string | null;
+ onSelect: (key: string) => void;
+}) {
+ const { t, vis } = useCopy();
+ const unknown = vis ? "—" : t("stats.unknown");
+ const numberValue = (
+ value: number | null | undefined,
+ digits: number,
+ unit = "",
+ ): string =>
+ finite(value ?? null) ? `${value!.toFixed(digits)}${unit}` : unknown;
+ const heading = (key: CopyKey, icon: GlyphName) => (
+ <span title={vis ? t(key) : undefined} aria-label={t(key)}>
+ {vis ? <Glyph name={icon} size={14} /> : t(key)}
+ </span>
+ );
+
+ return (
+ <section
+ className="lr-viewer-overview"
+ id="host-viewer-overview"
+ aria-label={t("host.viewerOverview")}
+ >
+ <div className="lr-viewer-overview-scroll">
+ <div className="lr-viewer-overview-head" aria-hidden="true">
+ <span>{vis ? <Glyph name="users" size={14} /> : t("common.viewers")}</span>
+ <span>{vis ? <Glyph name="network" size={14} /> : t("host.topology")}</span>
+ {heading("stats.resolution", "expand")}
+ {heading("stats.fps", "wave")}
+ {heading("stats.bitrate", "gauge")}
+ {heading("stats.loss", "drop")}
+ {heading("stats.rtt", "clock")}
+ </div>
+ <div className="lr-viewer-overview-body">
+ {entries.map((entry) => {
+ const metrics = entry.metrics;
+ const resolution = metrics?.resolution ?? unknown;
+ const fps = numberValue(metrics?.framesPerSecond, 1);
+ const bitrate = numberValue(metrics?.bitrateKbps, 0);
+ const loss = metrics
+ ? formatPacketLossPercent(metrics.packetLossPercent, unknown)
+ : unknown;
+ const rtt = numberValue(metrics?.rttMs, 0, " ms");
+ const route =
+ entry.route === "sfu"
+ ? "SFU"
+ : entry.route === "p2p"
+ ? "P2P"
+ : "—";
+ return (
+ <button
+ key={entry.key}
+ type="button"
+ className={`lr-viewer-overview-row${selectedKey === entry.key ? " is-selected" : ""}`}
+ aria-pressed={selectedKey === entry.key}
+ aria-label={`${entry.name} · ${entry.statusLabel} · ${route}`}
+ onClick={() => onSelect(entry.key)}
+ >
+ <span className="lr-viewer-overview-person" title={entry.statusLabel}>
+ <span className="lr-viewer-overview-pawn">
+ <PawnSvg color={pawnColor(entry.key)} />
+ <i className={entry.connected ? "" : "is-wait"} aria-hidden="true" />
+ </span>
+ <span className="lr-viewer-overview-person-copy">
+ <b>{entry.name}</b>
+ {vis ? null : <small>{entry.statusLabel}</small>}
+ </span>
+ </span>
+ <span className={`lr-viewer-overview-route is-${entry.route ?? "pending"}`}>
+ <Glyph
+ name={
+ entry.route === "sfu"
+ ? "server"
+ : entry.route === "p2p"
+ ? "network"
+ : "loader"
+ }
+ size={14}
+ />
+ <b>{route}</b>
+ </span>
+ <span>{resolution}</span>
+ <span>{fps}</span>
+ <span>{bitrate}</span>
+ <span>{loss}</span>
+ <span>{rtt}</span>
+ </button>
+ );
+ })}
+ </div>
+ </div>
+ </section>
+ );
+}
diff --git a/src/client/components/living/hints/set2.tsx b/src/client/components/living/hints/set2.tsx
index d92a3222..f18783e4 100644
--- a/src/client/components/living/hints/set2.tsx
+++ b/src/client/components/living/hints/set2.tsx
@@ -374,8 +374,22 @@ const ScenePolicyPrivate: HintScene = ({ theme }) => (
<>
<style>{`
.vls-priv-eyes{transform-box:fill-box;transform-origin:center;animation:vlsPrivBlink 3s ease-in-out infinite}
+.vls-priv-card{transform-box:fill-box;transform-origin:center;animation:vlsPrivCard 3s ease-in-out infinite}
+.vls-priv-door{transform-box:fill-box;transform-origin:0% 50%;animation:vlsPrivDoor 3s cubic-bezier(.3,.8,.35,1) infinite}
+.vls-priv-lock{transform-box:fill-box;transform-origin:center;animation:vlsPrivLock 3s cubic-bezier(.3,1.4,.45,1) infinite}
+.vls-priv-click{transform-box:fill-box;transform-origin:center;animation:vlsPrivClick 3s ease-out infinite}
@keyframes vlsPrivBlink{0%,52%,60%,100%{transform:scaleY(1)}56%{transform:scaleY(.12)}}
-${rmBlock(["vls-priv-eyes"], [])}
+@keyframes vlsPrivCard{0%,8%{transform:translateY(2px) rotate(-3deg)}18%{transform:translateY(-3px) rotate(4deg)}28%,100%{transform:none}}
+@keyframes vlsPrivDoor{0%,10%{transform:scaleX(.18);opacity:.45}28%,100%{transform:scaleX(1);opacity:1}}
+@keyframes vlsPrivLock{0%,24%{transform:translateY(-6px);opacity:0}34%{transform:translateY(1px);opacity:1}40%,100%{transform:none;opacity:1}}
+@keyframes vlsPrivClick{0%,32%{opacity:0;transform:scale(.45)}38%{opacity:1;transform:scale(1.12)}48%,100%{opacity:0;transform:scale(1)}}
+${rmBlock(
+ ["vls-priv-eyes", "vls-priv-card", "vls-priv-door", "vls-priv-lock", "vls-priv-click"],
+ [
+ [".vls-priv-card,.vls-priv-door,.vls-priv-lock", "transform:none;opacity:1"],
+ [".vls-priv-click", "opacity:.65;transform:none"],
+ ],
+)}
`}</style>
<Frame x={4} w={152} theme={theme} />
<Frame x={164} w={152} theme={theme} />
@@ -385,43 +399,48 @@ ${rmBlock(["vls-priv-eyes"], [])}
<circle cx={201.8} cy={60} r={0.9} />
<circle cx={206.2} cy={60} r={0.9} />
</g>
- <g transform="rotate(-10 202 44)">
- <rect
- x={195}
- y={39}
- width={14}
- height={10}
- rx={2}
- fill="var(--paper)"
- stroke="var(--ink)"
- strokeWidth={1.5}
- />
+ <g className="vls-priv-card">
+ <g transform="rotate(-10 202 44)">
+ <rect
+ x={195}
+ y={39}
+ width={14}
+ height={10}
+ rx={2}
+ fill="var(--paper)"
+ stroke="var(--ink)"
+ strokeWidth={1.5}
+ />
+ <path
+ d="M197.5 42.5 h4 M197.5 45.5 h6"
+ stroke="var(--ink)"
+ strokeWidth={1.2}
+ strokeLinecap="round"
+ />
+ </g>
+ </g>
+ <Door x={224} y={18} className="vls-priv-door" />
+ <g className="vls-priv-lock">
<path
- d="M197.5 42.5 h4 M197.5 45.5 h6"
+ d="M235 38 v-5 a5.5 5.5 0 0 1 11 0 v5"
stroke="var(--ink)"
- strokeWidth={1.2}
+ strokeWidth={2.5}
+ fill="none"
strokeLinecap="round"
/>
+ <rect
+ x={232}
+ y={38}
+ width={16}
+ height={13}
+ rx={3}
+ fill={STAR_GOLD}
+ stroke="var(--ink)"
+ strokeWidth={2}
+ />
+ <circle cx={240} cy={44} r={1.8} fill="var(--ink)" />
</g>
- <Door x={224} y={18} />
- <path
- d="M235 38 v-5 a5.5 5.5 0 0 1 11 0 v5"
- stroke="var(--ink)"
- strokeWidth={2.5}
- fill="none"
- strokeLinecap="round"
- />
- <rect
- x={232}
- y={38}
- width={16}
- height={13}
- rx={3}
- fill={STAR_GOLD}
- stroke="var(--ink)"
- strokeWidth={2}
- />
- <circle cx={240} cy={44} r={1.8} fill="var(--ink)" />
+ <Spark x={253} y={35} className="vls-priv-click" />
</>
);
diff --git a/src/client/lib/display-name.ts b/src/client/lib/display-name.ts
index e9e482a5..d6ccf242 100644
--- a/src/client/lib/display-name.ts
+++ b/src/client/lib/display-name.ts
@@ -29,15 +29,33 @@ export function readDisplayName(
return readStoredDisplayName() ?? fallback;
}
-export function defaultHostDisplayName(clientId: string): DisplayName {
+function suffixedDefaultName(prefix: string, clientId: string): DisplayName {
const suffix = clientId.slice(-6);
- const prefix = say("common.name.hostDefault");
return (
normalizeDisplayName(suffix ? `${prefix}-${suffix}` : prefix) ??
(prefix as DisplayName)
);
}
+export function defaultViewerDisplayName(
+ clientId: string,
+ visual: boolean,
+): DisplayName {
+ return visual
+ ? suffixedDefaultName("👀", clientId)
+ : (say("common.name.viewerDefault") as DisplayName);
+}
+
+export function defaultHostDisplayName(
+ clientId: string,
+ visual = false,
+): DisplayName {
+ return suffixedDefaultName(
+ visual ? "📺" : say("common.name.hostDefault"),
+ clientId,
+ );
+}
+
export function saveDisplayName(
value: string,
fallback: DisplayName = say("common.name.viewerDefault") as DisplayName,
diff --git a/src/client/lib/viewer-presence.ts b/src/client/lib/viewer-presence.ts
index 5edf389f..b3a644f3 100644
--- a/src/client/lib/viewer-presence.ts
+++ b/src/client/lib/viewer-presence.ts
@@ -26,6 +26,13 @@ export interface LabeledParticipantSnapshot {
const MIN_PEER_ID_SUFFIX_LENGTH = 6;
+function comparePeerIdentity(
+ left: PresenceIdentity,
+ right: PresenceIdentity,
+): number {
+ return left.peerId < right.peerId ? -1 : left.peerId > right.peerId ? 1 : 0;
+}
+
function labelPresence<T extends PresenceIdentity>(
entries: readonly T[],
): LabeledPresence<T>[] {
@@ -89,7 +96,7 @@ function labelPresence<T extends PresenceIdentity>(
export function labelViewerPresence(
viewers: readonly ViewerPresenceEntry[],
): LabeledViewerPresence[] {
- return labelPresence(viewers);
+ return labelPresence(viewers).sort(comparePeerIdentity);
}
export function labelParticipantSnapshot(
@@ -102,10 +109,12 @@ export function labelParticipantSnapshot(
(participant): participant is LabeledHostPresence =>
participant.role === "host",
) ?? null,
- viewers: labeled.filter(
- (participant): participant is LabeledViewerPresence =>
- participant.role === "viewer",
- ),
+ viewers: labeled
+ .filter(
+ (participant): participant is LabeledViewerPresence =>
+ participant.role === "viewer",
+ )
+ .sort(comparePeerIdentity),
};
}
diff --git a/src/client/locales/en.ts b/src/client/locales/en.ts
new file mode 100644
index 00000000..3232cdf3
--- /dev/null
+++ b/src/client/locales/en.ts
@@ -0,0 +1,419 @@
+import type { CopyKey, TitleFrameCatalog } from "./zh";
+
+// Community translations are data-only and type-checked against zh.
+export const en: Record<CopyKey, string> = {
+ "brand.home": "Screener home",
+
+ "common.roomCode": "Room code",
+ "common.copy": "Copy",
+ "common.copied": "Copied",
+ "common.copyFailed": "Copy failed",
+ "common.cancel": "Cancel",
+ "common.retry": "Retry",
+ "common.refresh": "Refresh page",
+ "common.edit": "Edit",
+ "common.close": "Close",
+ "common.viewers": "Viewers",
+ "common.you": "you",
+ "common.host": "Host",
+ "common.name.viewerDefault": "Viewer",
+ "common.name.hostDefault": "Host",
+ "page.room": "Room {room}",
+
+ "gate.title": "Site access",
+ "gate.hint": "Enter the site passphrase",
+ "gate.password": "Site passphrase",
+ "gate.submit": "Enter site",
+ "gate.checking": "Checking site access",
+ "gate.wrong": "Incorrect passphrase, try again",
+ "gate.unavailable": "Site access cannot be verified right now",
+ "gate.malformed": "Invalid room code format",
+ "gate.malformedHint": "Enter a four-digit room code between 1000 and 9999",
+ "gate.unavailableRoute": "Unavailable",
+
+ "join.title": "Join a room",
+ "join.hint": "Enter the four-digit room code from your friend",
+ "join.field": "Room code",
+ "join.submit": "Join",
+ "join.invalid": "Enter a four-digit room code between 1000 and 9999",
+ "join.joining": "Joining the room",
+ "join.notFound": "Room not found or expired",
+ "join.notFoundHint": "Check the room code, or ask the host for a new invite link.",
+ "join.denied": "This room cannot be joined by code right now",
+ "join.deniedHint": "Use the host's invite link, or try the room password.",
+ "join.password": "Room password",
+ "join.passwordError": "Could not join; try again",
+ "join.passwordRule": "Enter 1-{max} visible characters",
+ "join.passwordAction": "Enter room password",
+ "join.full": "Room is full",
+
+ "host.title": "{name}'s screen",
+ "host.idle.heading": "Something worth watching?",
+ "host.idle.hint": "Share your screen and friends can drop in with the room code or invite link.",
+ "host.start": "Start sharing",
+ "host.join": "Join a room",
+ "host.starting": "Connecting",
+ "host.cancelStart": "Cancel",
+ "host.live": "Sharing",
+ "host.paused": "Paused",
+ "host.ended": "Sharing stopped",
+ "host.roomReady": "Room ready",
+ "host.pause": "Pause sharing",
+ "host.resume": "Resume sharing",
+ "host.switchSource": "Switch source",
+ "host.switching": "Choosing",
+ "host.stop": "Stop sharing",
+ "host.noAudio": "This source has no shareable audio",
+ "host.localPreviewPaused": "Local preview paused; sharing continues",
+ "host.pauseNotice": "Audio and video sharing paused",
+ "host.resumeNotice": "Audio and video sharing resumed",
+ "host.stopNotice": "Sharing stopped",
+ "host.roomReplaced": "Room code replaced",
+ "host.roomInvalid": "Room expired; press again to create a new one",
+ "host.roomReplace": "Replace room code",
+ "host.roomReplaceConfirm": "Confirm replacing the room code",
+ "host.captureError": "Screen capture unavailable; check browser permission and retry",
+ "host.terminated.stale": "Page updated; refresh to continue",
+ "host.terminated.session": "This page's session was taken over by another tab",
+ "host.terminated.signal": "Server connection terminated; refresh to continue",
+ "host.notice.qualityApplied": "Share settings applied",
+ "host.notice.qualitySet": "Quality switched to {label}",
+ "host.notice.audioSet": "Audio quality switched to {label}",
+ "host.notice.partialApply": "Settings updated, but some viewer connections could not apply them",
+ "host.notice.sourceSwitch.ok": "Share source switched",
+ "host.notice.sourceSwitch.partial": "Source switched, but {warning}",
+
+ "host.name": "Display name",
+ "host.nameSave": "Save display name",
+ "host.nameCancel": "Cancel editing",
+ "host.nameEdit": "Edit display name",
+ "host.nameError": "Invalid name, or longer than 24 characters",
+ "host.nameOffline": "Display name can only change while sharing and connected",
+
+ "host.invite": "Invite link",
+ "host.invite.copy": "Copy invite link",
+ "host.invite.copyFailed": "Could not copy the invite link; try again",
+ "host.invite.rotate": "Rotate invite link",
+ "host.invite.revoke": "Revoke invite link",
+ "host.invite.rotateShort": "Rotate link",
+ "host.invite.revokeShort": "Revoke link",
+ "host.invite.updated": "Invite link rotated",
+ "host.invite.revoked": "Invite link revoked",
+ "host.invite.emptyOpen": "No invite link; the room code still works",
+ "host.invite.emptyPassword": "No invite link; room code plus password still works",
+ "host.invite.emptyPrivate": "No invite link; rotate one before inviting",
+
+ "host.policy": "Admission",
+ "host.policy.open": "Open",
+ "host.policy.private": "Private",
+ "host.policy.openHint": "Anyone with the room code can join",
+ "host.policy.privateHint": "Invite link only, or set a room password",
+ "host.policy.setOpen": "Room is now open",
+ "host.policy.setPrivateInvite": "Room is now private, invite link only",
+ "host.policy.setPrivatePassword": "Room is now private, invite link or password",
+ "host.password.set": "Room password set",
+ "host.password.unset": "No room password",
+ "host.password.placeholder": "Set one to allow code entry",
+ "host.password.setAction": "Set room password",
+ "host.password.changeAction": "Change room password",
+ "host.password.remove": "Remove room password",
+ "host.password.show": "Show room password",
+ "host.password.hide": "Hide room password",
+ "host.password.saved": "Room password set",
+ "host.password.updated": "Room password updated",
+ "host.password.removed": "Password removed; invite link only",
+ "host.password.rule": "1-{max} visible characters",
+ "host.accessFailed": "Cannot update room settings right now; try again later",
+
+ "host.viewers.empty": "No viewers yet",
+ "host.viewers.waiting": "Waiting for friends to join",
+ "host.viewerOverview": "All viewer connections",
+
+ "host.quality": "Video preset",
+ "host.quality.720p30": "720p · 30 fps",
+ "host.quality.1080p30": "1080p · 30 fps",
+ "host.quality.1080p60": "1080p · 60 fps",
+ "host.advanced": "Advanced settings",
+ "host.advanced.resolution": "Resolution ceiling",
+ "host.advanced.framerate": "Frame rate ceiling",
+ "host.advanced.bitrate": "Video bitrate ceiling",
+ "host.advanced.preference": "Picture preference",
+ "host.advanced.preference.resolution": "Clarity",
+ "host.advanced.preference.balanced": "Balanced",
+ "host.advanced.preference.framerate": "Fluency",
+ "host.advanced.preference.resolutionHint": "Keep detail",
+ "host.advanced.preference.balancedHint": "Weigh automatically",
+ "host.advanced.preference.framerateHint": "Prefer frame rate",
+ "host.advanced.audio": "Audio quality",
+ "host.advanced.audio.saver": "Standard",
+ "host.advanced.audio.music": "Music",
+ "host.advanced.audio.veryHigh": "Studio",
+ "host.advanced.route": "Route policy",
+ "host.advanced.route.topo": "Auto topology tuning",
+ "host.advanced.route.topoHint": "Gradually pick healthier paths while live",
+ "host.advanced.route.peerOnly": "Privacy mode",
+ "host.advanced.route.peerOnlyHint":
+ "Use P2P routes only; viewers without a P2P path cannot watch",
+ "host.advanced.codec": "Video codec",
+ "host.advanced.codec.auto": "Auto",
+ "host.advanced.codec.autoHint": "Pick automatically",
+ "host.advanced.codec.vp8Hint": "Compatibility first",
+ "host.advanced.codec.h264Hint": "Hardware first",
+
+ "host.details": "Show connection details",
+ "host.details.hide": "Hide connection details",
+ "host.topology": "Connection topology",
+ "host.topology.show": "Show connection topology",
+ "host.topology.hide": "Hide connection topology",
+ "host.topology.pending": "Connecting",
+ "host.sfu": "Media server",
+
+ "state.signal.connected": "Server connected",
+ "state.signal.connecting": "Connecting",
+ "state.signal.reconnecting": "Recovering",
+ "state.signal.offline": "Server offline",
+ "state.peer.connected": "Connected",
+ "state.peer.connecting": "Connecting",
+ "state.peer.routing": "Routing",
+ "state.peer.waiting": "Waiting for share",
+ "state.peer.reconnecting": "Recovering",
+ "state.peer.failed": "Connection failed",
+ "state.peer.disconnected": "Connection lost",
+ "state.peer.closed": "Closed",
+ "state.peer.new": "Preparing",
+ "state.route.p2p": "P2P direct",
+ "state.route.sfu": "Via server",
+
+ "stats.title": "Connection data",
+ "stats.relay": "Relay data",
+ "stats.downstream": "Downstream receive data",
+ "stats.more": "Detailed metrics",
+ "stats.less": "Hide detailed metrics",
+ "stats.resolution": "Resolution",
+ "stats.fps": "Frame rate",
+ "stats.bitrate": "Bitrate",
+ "stats.loss": "Packet loss",
+ "stats.rtt": "RTT",
+ "stats.codec": "Video codec",
+ "stats.jitter": "Jitter",
+ "stats.dropped": "Dropped frames",
+ "stats.encoder": "Encoder",
+ "stats.audio": "Audio bitrate",
+ "stats.unknown": "Unknown",
+ "stats.outgoing": "Available uplink",
+ "stats.qualityState": "Quality state",
+ "stats.quality.normal": "Normal",
+ "stats.quality.bandwidth": "Bandwidth-limited",
+ "stats.quality.cpu": "Encoder-limited",
+ "stats.quality.other": "Other limit",
+ "stats.quality.unclassified": "Unclassified limit",
+ "stats.capture": "Capture settings",
+ "stats.inputFps": "Encoder input rate",
+ "stats.encodeMs": "Encode time/frame",
+ "stats.decodeMs": "Decode time/frame",
+ "stats.freezeCount": "Freezes",
+ "stats.freezeDuration": "Freeze duration",
+ "stats.audioLoss": "Audio packet loss",
+ "stats.audioJitter": "Audio jitter",
+ "stats.playoutDelta": "A/V playout delta",
+ "stats.videoBuffer": "Video buffer",
+ "stats.audioBuffer": "Audio buffer",
+ "stats.audioConcealedRate": "Audio concealment rate",
+ "stats.audioConcealed": "Audio concealments",
+
+ "viewer.title": "{name}'s screen",
+ "viewer.titleFallback": "A friend's screen",
+ "viewer.title.watching": "Watching",
+ "viewer.title.waiting": "Waiting",
+ "viewer.reconnect": "Reconnect media",
+ "viewer.theater": "Theater mode",
+ "viewer.theater.exit": "Exit theater mode",
+ "viewer.msg.joining": "Joining the room",
+ "viewer.msg.waitingHost": "Waiting for the host to share",
+ "viewer.msg.preparingP2p": "Establishing P2P",
+ "viewer.msg.preparingSfu": "Connecting backup route",
+ "viewer.msg.allocating": "Allocating a route",
+ "viewer.msg.receiving": "Receiving video",
+ "viewer.msg.playing": "Playing",
+ "viewer.msg.needsPlay": "Tap to play",
+ "viewer.msg.hostPaused": "Host paused",
+ "viewer.msg.recovering": "Recovering connection",
+ "viewer.msg.routeFailed": "No media route available",
+ "viewer.msg.playbackFailed": "The browser cannot play this stream",
+ "viewer.msg.hostOffline": "Host connection lost",
+ "viewer.msg.serverError": "Connection service unavailable",
+ "viewer.msg.notFound": "Room not found or expired",
+ "viewer.msg.denied": "This room cannot be joined by code right now",
+ "viewer.msg.invalidInvite": "Invite link invalid or expired",
+ "viewer.msg.expired": "Room expired",
+ "viewer.msg.closed": "Room closed",
+ "viewer.msg.full": "Cannot join the room right now",
+ "viewer.msg.stale": "Page updated; refresh to continue",
+ "viewer.msg.sessionReplaced": "This page's session was taken over by another tab",
+ "viewer.msg.signalTerminated": "Connection terminated; refresh to continue",
+ "viewer.notice.signalRecovering": "Server reconnecting; video keeps playing",
+ "viewer.notice.mediaRecovering": "Media connection recovering",
+ "viewer.notice.hostOffline": "Host connection lost; picture may freeze",
+ "viewer.hint.denied": "Use the host's invite link, or try the room password.",
+ "viewer.hint.notFound": "Check the room code, or ask the host for a new invite link.",
+ "viewer.hint.invite": "Ask the host for a new invite link.",
+ "viewer.hint.generic": "Check your entry point and try again.",
+ "viewer.error.p2p": "P2P media connection error",
+ "viewer.error.relay": "Downstream media connection error",
+
+ "mode.language": "Interface language",
+ "mode.zh": "中文",
+ "mode.en": "English",
+ "mode.vis": "Visual only",
+ "theme.dark": "Switch to dark mode",
+ "theme.light": "Switch to light mode",
+ "theme.dark.short": "Dark",
+ "theme.light.short": "Light",
+
+ "story.room": "Room found",
+ "story.link": "Linking up",
+ "story.show": "Receiving picture",
+
+ "gate.connectFailed": "Cannot reach the site access service; try again",
+ "gate.expired": "Site access expired; verify again",
+ "gate.serviceUnavailable": "Site access service unavailable ({status})",
+
+ "host.onlineCount": "{n} / {max} online",
+ "host.notStarted": "Not started",
+ "host.startCancelled": "Start cancelled",
+ "host.switchingSource": "Switching source",
+ "host.capture.fpsUnknown": "Unknown frame rate",
+ "host.capture.codecPending": "Codec pending",
+ "host.capture.hasAudio": "With audio",
+ "host.capture.noAudio": "No audio",
+ "host.stageAria": "Share or join a room",
+ "host.captureAria": "Actual capture parameters",
+ "host.quality.title": "{label} · {mbps} Mbps",
+ "host.audio.title": "{label} · {kbps} kbps ceiling",
+ "host.roomExpired": "Room expired",
+ "host.roomClosed": "Room closed",
+ "host.pause.noTracksResume": "No resumable media tracks in the current share",
+ "host.pause.signalRecovering": "Server reconnecting; sharing stays paused",
+ "host.pause.noTracksPause": "No pausable media tracks in the current share",
+ "host.pause.stillPaused": "Sharing stays paused",
+ "host.shareEnded": "The current share has ended",
+ "host.fail.start": "Failed to start sharing",
+ "host.err.createConnection": "Failed to create the connection",
+ "host.err.codecUnsupported": "This browser cannot use a supported video codec",
+ "host.err.applySender": "Failed to apply sender parameters",
+ "host.err.applyAudioSender": "Failed to apply audio sender parameters",
+ "host.fail.source": "Failed to switch share source",
+ "host.fail.quality": "Failed to apply quality settings",
+ "host.fail.connection": "Viewer connection handling failed",
+ "host.fail.room": "Room operation failed",
+ "host.err.invalidToken": "Share credentials expired; create the room again",
+ "host.err.accessDenied": "Not permitted",
+ "host.err.roomExpired": "Room expired; create it again",
+ "host.err.alreadyConnected": "This room is already shared in another page",
+ "host.err.peerGone": "The viewer connection has left",
+ "host.err.forbidden": "Action unavailable",
+ "host.err.serverError": "Service temporarily unavailable; try again later",
+ "host.err.createRoomStatus": "Cannot create a room right now ({status})",
+ "host.err.replaceRoomStatus": "Cannot change rooms right now ({status})",
+ "host.err.updateRoomStatus": "Cannot update room settings right now ({status})",
+ "host.capture.cancelled": "Screen selection cancelled or not permitted",
+ "host.capture.noSource": "No shareable screen source available",
+ "host.capture.readFailed": "The browser cannot read the selected source right now",
+ "host.capture.unavailable": "This page cannot start screen sharing",
+ "host.notice.reconnecting": "Some viewers are reconnecting",
+ "host.notice.sfuRecovering": "SFU source switch failed; restoring viewer connections",
+ "host.password.inputPlaceholder": "Enter password",
+
+ "stats.warn.codec": "Video codec is {codec}; expected H264 or VP8",
+ "stats.warn.audioCodec": "Audio codec is {codec}; expected Opus",
+
+ "viewer.msg.joinUnavailable": "Cannot join the room right now",
+ "viewer.stageAria": "Shared picture",
+
+ "host.warn.audioUnread": "The browser did not report the audio bitrate ceiling",
+ "host.warn.bandwidth": "This connection is bandwidth-limited; quality was reduced automatically",
+ "host.warn.encoding": "Encoding performance is limited; quality was reduced automatically",
+ "host.warn.other": "The browser keeps reporting other quality limits",
+ "host.warn.unclassified": "The browser keeps reporting an unclassified quality limit",
+ "host.warn.audioRewritten": "The browser rewrote the audio bitrate ceiling to {kbps} kbps",
+ "host.warn.senderPartial": "The browser did not fully accept {params}",
+ "host.warn.param.maxBitrate": "bitrate ceiling",
+ "host.warn.param.maxFramerate": "frame rate ceiling",
+ "host.warn.param.scaleResolutionDownBy": "resolution scaling",
+ "host.warn.param.degradationPreference": "quality preference",
+ "host.warn.param.scalabilityMode": "scalability mode",
+ "host.warn.sfuRecover": "SFU {stage} failed; automatic recovery started",
+ "host.warn.sfuStage.connect": "connect",
+ "host.warn.sfuStage.source": "source",
+ "host.warn.sfuStage.videoPublish": "video publish",
+ "host.warn.sfuStage.senderConfig": "sender config",
+ "host.warn.sfuStage.audioPublish": "audio publish",
+ "host.warn.sfuStage.transport": "transport",
+ "host.fail.sfuSwitch": "Failed to switch the SFU share source",
+ "host.fail.sfuAudioParams": "Failed to apply SFU audio sender parameters",
+ "host.fail.sfuParams": "Failed to apply SFU sender parameters",
+};
+
+export const enTitleFrames = {
+ hostActive: [
+ en["host.live"],
+ "Screen's up",
+ "Sending pixels",
+ "Picture in motion",
+ "Tiny TV at work",
+ "Show time",
+ "Signal on its way",
+ "Pixels go brrr",
+ "Let it cook",
+ "The game's afoot",
+ "Curtain up",
+ "Tiny screen, big moment",
+ ],
+ viewerActive: [
+ en["viewer.title.watching"],
+ "Tuned in",
+ "Pixels incoming",
+ "Eyes on screen",
+ "Popcorn ready",
+ "Tiny TV rolling",
+ "Front-row seat",
+ "Let them cook",
+ "The game's afoot",
+ "Popcorn mode on",
+ "Tiny screen, big moment",
+ "Front row secured",
+ ],
+ paused: [en["host.paused"]],
+ hostStarting: [en["host.starting"], "Linking up", "Signals saying hello"],
+ hostEnded: [en["host.ended"]],
+ hostReady: [
+ en["host.roomReady"],
+ "Couch is ready",
+ "Ready when you are",
+ "Tiny TV standing by",
+ "Remote at the ready",
+ "Lights are set",
+ "Your channel awaits",
+ "Tea is ready",
+ ],
+ hostIdle: [
+ en["host.notStarted"],
+ "Tiny TV is resting",
+ "Waiting for a screen",
+ "Antenna taking a nap",
+ "Screen is dreaming",
+ "Remote is daydreaming",
+ "Waiting for showtime",
+ "Quiet little room",
+ ],
+ viewerWaiting: [
+ en["viewer.title.waiting"],
+ "Waiting for showtime",
+ "Getting the popcorn",
+ "Front row reserved",
+ "Couch saved you a spot",
+ "Remote in hand",
+ "Waiting for the picture",
+ "Audience standing by",
+ ],
+} satisfies TitleFrameCatalog;
diff --git a/src/client/locales/index.ts b/src/client/locales/index.ts
new file mode 100644
index 00000000..88582842
--- /dev/null
+++ b/src/client/locales/index.ts
@@ -0,0 +1,20 @@
+import { en, enTitleFrames } from "./en";
+import { visualTitleFrames } from "./visual";
+import {
+ zh,
+ zhTitleFrames,
+ type TitleFrameCatalog,
+} from "./zh";
+
+export type { CopyKey, TitleFrameKey } from "./zh";
+
+// Register contributed locales here; UI consumers stay catalog-agnostic.
+export const catalogs = { zh, en };
+export type Lang = keyof typeof catalogs;
+
+export const titleFrameCatalogs: Record<Lang, TitleFrameCatalog> = {
+ zh: zhTitleFrames,
+ en: enTitleFrames,
+};
+
+export { visualTitleFrames };
diff --git a/src/client/locales/visual.ts b/src/client/locales/visual.ts
new file mode 100644
index 00000000..1a29dbe4
--- /dev/null
+++ b/src/client/locales/visual.ts
@@ -0,0 +1,66 @@
+import type { TitleFrameCatalog } from "./zh";
+
+// Visual mode expresses the same title states without language-specific copy.
+export const visualTitleFrames = {
+ hostActive: [
+ "📺",
+ "📺 ✨",
+ "📺 🎮",
+ "📺 ⚡",
+ "📺 🌟",
+ "📺 🎬",
+ "📺 🪄",
+ "📺 🚀",
+ "📺 🔥",
+ "📺 🫡",
+ "📺 🌀",
+ "📺 🕹️",
+ ],
+ viewerActive: [
+ "📺",
+ "📺 ✨",
+ "📺 🍿",
+ "📺 👀",
+ "📺 🌟",
+ "📺 🛋️",
+ "📺 🎬",
+ "📺 💫",
+ "📺 🔥",
+ "📺 🤩",
+ "📺 🥤",
+ "📺 🪄",
+ ],
+ paused: ["⏸️"],
+ hostStarting: ["⏳", "⏳ 🔗", "⏳ 📶"],
+ hostEnded: ["⏹️"],
+ hostReady: [
+ "🛋️",
+ "🛋️ ✨",
+ "🛋️ 🎬",
+ "🛋️ 📺",
+ "🛋️ 🍵",
+ "🛋️ 🎮",
+ "🛋️ 🌟",
+ "🛋️ 🫡",
+ ],
+ hostIdle: [
+ "💤",
+ "📺 💤",
+ "💤 🌙",
+ "📺 🌙",
+ "📺 ☁️",
+ "🛋️ 💤",
+ "📺 🫧",
+ "💤 ✨",
+ ],
+ viewerWaiting: [
+ "⏳",
+ "⏳ 👀",
+ "⏳ 🍿",
+ "⏳ 🛋️",
+ "⏳ 📺",
+ "⏳ ✨",
+ "⏳ 🥤",
+ "⏳ 🎬",
+ ],
+} satisfies TitleFrameCatalog;
diff --git a/src/client/locales/zh.ts b/src/client/locales/zh.ts
new file mode 100644
index 00000000..15b318b7
--- /dev/null
+++ b/src/client/locales/zh.ts
@@ -0,0 +1,425 @@
+// Canonical catalog: add keys here first; every other locale must match it.
+export const zh = {
+ "brand.home": "Screener 首页",
+
+ "common.roomCode": "房间号",
+ "common.copy": "复制",
+ "common.copied": "已复制",
+ "common.copyFailed": "复制失败",
+ "common.cancel": "取消",
+ "common.retry": "重试",
+ "common.refresh": "刷新页面",
+ "common.edit": "编辑",
+ "common.close": "收起",
+ "common.viewers": "观看者",
+ "common.you": "你",
+ "common.host": "分享者",
+ "common.name.viewerDefault": "观众",
+ "common.name.hostDefault": "分享者",
+ "page.room": "房间 {room}",
+
+ "gate.title": "站点访问",
+ "gate.hint": "请输入站点口令",
+ "gate.password": "站点口令",
+ "gate.submit": "进入站点",
+ "gate.checking": "正在验证站点访问",
+ "gate.wrong": "站点口令不正确,请重试",
+ "gate.unavailable": "暂时无法验证站点访问",
+ "gate.malformed": "房间号格式不正确",
+ "gate.malformedHint": "请输入 1000 至 9999 的四位房间号",
+ "gate.unavailableRoute": "无法访问",
+
+ "join.title": "加入房间",
+ "join.hint": "输入分享者提供的房间号",
+ "join.field": "房间号",
+ "join.submit": "加入",
+ "join.invalid": "请输入 1000 至 9999 的四位房间号",
+ "join.joining": "正在加入房间",
+ "join.notFound": "房间不存在或已过期",
+ "join.notFoundHint": "请确认房间号,或向分享者获取新的邀请链接。",
+ "join.denied": "当前无法通过房间号加入",
+ "join.deniedHint": "请使用分享者提供的邀请链接,或尝试房间密码。",
+ "join.password": "房间密码",
+ "join.passwordError": "无法加入房间,请重试",
+ "join.passwordRule": "请输入 1-{max} 个可见字符",
+ "join.passwordAction": "输入房间密码",
+ "join.full": "房间已满",
+
+ "host.title": "{name} 的屏幕",
+ "host.idle.heading": "想播点什么?",
+ "host.idle.hint": "分享你的屏幕,朋友凭房间号或邀请链接就能进来看。",
+ "host.start": "开始分享",
+ "host.join": "加入房间",
+ "host.starting": "正在连接",
+ "host.cancelStart": "取消",
+ "host.live": "分享中",
+ "host.paused": "已暂停",
+ "host.ended": "已停止分享",
+ "host.roomReady": "房间已就绪",
+ "host.pause": "暂停分享",
+ "host.resume": "恢复分享",
+ "host.switchSource": "切换来源",
+ "host.switching": "正在选择",
+ "host.stop": "停止分享",
+ "host.noAudio": "当前来源没有可共享音频",
+ "host.localPreviewPaused": "本地预览已暂停,分享仍在继续",
+ "host.pauseNotice": "音视频分享已暂停",
+ "host.resumeNotice": "音视频分享已恢复",
+ "host.stopNotice": "已停止分享",
+ "host.roomReplaced": "房间号已更换",
+ "host.roomInvalid": "房间已失效,再次点击将创建新房",
+ "host.roomReplace": "更换房间号",
+ "host.roomReplaceConfirm": "确认更换房间号",
+ "host.captureError": "无法开始屏幕采集,请检查浏览器权限后重试",
+ "host.terminated.stale": "页面版本已更新,请刷新后重试",
+ "host.terminated.session": "此页面的会话已被另一个标签页接管",
+ "host.terminated.signal": "服务器连接已终止,请刷新后重试",
+ "host.notice.qualityApplied": "分享设置已应用",
+ "host.notice.qualitySet": "画质已切换为 {label}",
+ "host.notice.audioSet": "音频质量已切换为 {label}",
+ "host.notice.partialApply": "分享设置已更新,但部分观看连接未能应用新参数",
+ "host.notice.sourceSwitch.ok": "分享来源已切换",
+ "host.notice.sourceSwitch.partial": "分享来源已切换,但{warning}",
+
+ "host.name": "昵称",
+ "host.nameSave": "保存昵称",
+ "host.nameCancel": "取消编辑昵称",
+ "host.nameEdit": "编辑昵称",
+ "host.nameError": "名称格式无效或超过 24 个字符",
+ "host.nameOffline": "开始分享并连接后才能修改昵称",
+
+ "host.invite": "邀请链接",
+ "host.invite.copy": "复制邀请链接",
+ "host.invite.copyFailed": "无法复制邀请链接,请稍后重试",
+ "host.invite.rotate": "更新邀请链接",
+ "host.invite.revoke": "撤销邀请链接",
+ "host.invite.rotateShort": "更新链接",
+ "host.invite.revokeShort": "撤销链接",
+ "host.invite.updated": "邀请链接已更新",
+ "host.invite.revoked": "邀请链接已撤销",
+ "host.invite.emptyOpen": "暂无邀请链接,仍可凭房间号加入",
+ "host.invite.emptyPassword": "暂无邀请链接,仍可凭房间号和密码加入",
+ "host.invite.emptyPrivate": "暂无邀请链接,请先更新链接再邀请他人",
+
+ "host.policy": "准入方式",
+ "host.policy.open": "公开",
+ "host.policy.private": "私密",
+ "host.policy.openHint": "知道房间号即可加入",
+ "host.policy.privateHint": "凭邀请链接加入,或设置房间密码",
+ "host.policy.setOpen": "房间已设为公开",
+ "host.policy.setPrivateInvite": "房间已设为私密,仅限邀请加入",
+ "host.policy.setPrivatePassword": "房间已设为私密,可凭邀请或密码加入",
+ "host.password.set": "房间密码已设置",
+ "host.password.unset": "房间密码未设置",
+ "host.password.placeholder": "设置后可凭房间号加入",
+ "host.password.setAction": "设置房间密码",
+ "host.password.changeAction": "更改房间密码",
+ "host.password.remove": "移除房间密码",
+ "host.password.show": "显示房间密码",
+ "host.password.hide": "隐藏房间密码",
+ "host.password.saved": "房间密码已设置",
+ "host.password.updated": "房间密码已更新",
+ "host.password.removed": "房间密码已移除,仅限邀请加入",
+ "host.password.rule": "房间密码只需 1-{max} 个可见字符",
+ "host.accessFailed": "当前无法更新房间设置,请稍后重试",
+
+ "host.viewers.empty": "暂无观看者",
+ "host.viewers.waiting": "等待朋友加入",
+ "host.viewerOverview": "全员连接数据",
+
+ "host.quality": "视频预设",
+ "host.quality.720p30": "720p · 30 帧",
+ "host.quality.1080p30": "1080p · 30 帧",
+ "host.quality.1080p60": "1080p · 60 帧",
+ "host.advanced": "高级设置",
+ "host.advanced.resolution": "分辨率上限",
+ "host.advanced.framerate": "帧率上限",
+ "host.advanced.bitrate": "视频码率上限",
+ "host.advanced.preference": "画面偏好",
+ "host.advanced.preference.resolution": "清晰",
+ "host.advanced.preference.balanced": "均衡",
+ "host.advanced.preference.framerate": "流畅",
+ "host.advanced.preference.resolutionHint": "保留细节",
+ "host.advanced.preference.balancedHint": "自动权衡",
+ "host.advanced.preference.framerateHint": "优先帧率",
+ "host.advanced.audio": "音频质量",
+ "host.advanced.audio.saver": "普通",
+ "host.advanced.audio.music": "音乐",
+ "host.advanced.audio.veryHigh": "保真",
+ "host.advanced.route": "路由策略",
+ "host.advanced.route.topo": "自动优化拓扑",
+ "host.advanced.route.topoHint": "观看中逐步选择更健康的连接",
+ "host.advanced.route.peerOnly": "隐私模式",
+ "host.advanced.route.peerOnlyHint":
+ "仅使用 P2P 路线,不经过媒体服务器;无可用 P2P 路线时无法观看",
+ "host.advanced.codec": "视频编码",
+ "host.advanced.codec.auto": "自动",
+ "host.advanced.codec.autoHint": "自动选择",
+ "host.advanced.codec.vp8Hint": "兼容优先",
+ "host.advanced.codec.h264Hint": "硬件优先",
+
+ "host.details": "显示连接详情",
+ "host.details.hide": "隐藏连接详情",
+ "host.topology": "连接拓扑",
+ "host.topology.show": "显示连接拓扑",
+ "host.topology.hide": "隐藏连接拓扑",
+ "host.topology.pending": "连接中",
+ "host.sfu": "媒体服务器",
+
+ "state.signal.connected": "服务器已连接",
+ "state.signal.connecting": "正在连接",
+ "state.signal.reconnecting": "正在恢复",
+ "state.signal.offline": "服务器未连接",
+ "state.peer.connected": "已连接",
+ "state.peer.connecting": "正在连接",
+ "state.peer.routing": "线路分配中",
+ "state.peer.waiting": "等待开始分享",
+ "state.peer.reconnecting": "正在恢复",
+ "state.peer.failed": "连接失败",
+ "state.peer.disconnected": "连接中断",
+ "state.peer.closed": "已关闭",
+ "state.peer.new": "准备中",
+ "state.route.p2p": "P2P 直连",
+ "state.route.sfu": "服务器中转",
+
+ "stats.title": "连接数据",
+ "stats.relay": "转发数据",
+ "stats.downstream": "下游接收数据",
+ "stats.more": "详细指标",
+ "stats.less": "收起详细指标",
+ "stats.resolution": "分辨率",
+ "stats.fps": "帧率",
+ "stats.bitrate": "码率",
+ "stats.loss": "丢包率",
+ "stats.rtt": "RTT",
+ "stats.codec": "视频编码",
+ "stats.jitter": "网络抖动",
+ "stats.dropped": "丢帧",
+ "stats.encoder": "编码器",
+ "stats.audio": "音频码率",
+ "stats.unknown": "未知",
+ "stats.outgoing": "可用上行",
+ "stats.qualityState": "质量状态",
+ "stats.quality.normal": "正常",
+ "stats.quality.bandwidth": "带宽受限",
+ "stats.quality.cpu": "编码受限",
+ "stats.quality.other": "其他限制",
+ "stats.quality.unclassified": "未分类限制",
+ "stats.capture": "捕获设置",
+ "stats.inputFps": "编码输入帧率",
+ "stats.encodeMs": "编码耗时/帧",
+ "stats.decodeMs": "解码耗时/帧",
+ "stats.freezeCount": "画面冻结",
+ "stats.freezeDuration": "冻结时长",
+ "stats.audioLoss": "音频丢包率",
+ "stats.audioJitter": "音频抖动",
+ "stats.playoutDelta": "音视频播放差",
+ "stats.videoBuffer": "视频缓冲",
+ "stats.audioBuffer": "音频缓冲",
+ "stats.audioConcealedRate": "音频补偿率",
+ "stats.audioConcealed": "音频补偿",
+
+ "viewer.title": "{name} 的屏幕",
+ "viewer.titleFallback": "好友屏幕",
+ "viewer.title.watching": "观看中",
+ "viewer.title.waiting": "等待中",
+ "viewer.reconnect": "重新连接媒体",
+ "viewer.theater": "剧场模式",
+ "viewer.theater.exit": "退出剧场模式",
+ "viewer.msg.joining": "正在加入房间",
+ "viewer.msg.waitingHost": "等待开始分享",
+ "viewer.msg.preparingP2p": "正在建立 P2P",
+ "viewer.msg.preparingSfu": "正在连接备用线路",
+ "viewer.msg.allocating": "正在分配线路",
+ "viewer.msg.receiving": "正在接收画面",
+ "viewer.msg.playing": "正在播放",
+ "viewer.msg.needsPlay": "点击播放",
+ "viewer.msg.hostPaused": "分享者已暂停",
+ "viewer.msg.recovering": "正在恢复连接",
+ "viewer.msg.routeFailed": "没有可用的媒体线路",
+ "viewer.msg.playbackFailed": "浏览器无法播放当前画面",
+ "viewer.msg.hostOffline": "分享者连接已中断",
+ "viewer.msg.serverError": "连接服务暂时不可用",
+ "viewer.msg.notFound": "房间不存在或已过期",
+ "viewer.msg.denied": "当前无法通过房间号加入",
+ "viewer.msg.invalidInvite": "邀请链接无效或已失效",
+ "viewer.msg.expired": "房间已过期",
+ "viewer.msg.closed": "房间已关闭",
+ "viewer.msg.full": "当前无法加入房间",
+ "viewer.msg.stale": "页面版本已更新,请刷新后重试",
+ "viewer.msg.sessionReplaced": "此页面的会话已被另一个标签页接管",
+ "viewer.msg.signalTerminated": "连接已终止,请刷新后重试",
+ "viewer.notice.signalRecovering": "服务器连接正在恢复,画面仍在播放",
+ "viewer.notice.mediaRecovering": "媒体连接正在恢复",
+ "viewer.notice.hostOffline": "分享者连接已中断,画面可能冻结",
+ "viewer.hint.denied": "请使用分享者提供的邀请链接,或尝试房间密码。",
+ "viewer.hint.notFound": "请确认房间号,或向分享者获取新的邀请链接。",
+ "viewer.hint.invite": "请向分享者获取新的邀请链接。",
+ "viewer.hint.generic": "请检查入口后重试。",
+ "viewer.error.p2p": "P2P 媒体连接异常",
+ "viewer.error.relay": "下游媒体连接异常",
+
+ "mode.language": "界面语言",
+ "mode.zh": "中文",
+ "mode.en": "English",
+ "mode.vis": "纯视觉",
+ "theme.dark": "切换到暗色模式",
+ "theme.light": "切换到浅色模式",
+ "theme.dark.short": "暗色",
+ "theme.light.short": "浅色",
+
+ "story.room": "找到房间",
+ "story.link": "建立连接",
+ "story.show": "接收画面",
+
+ "gate.connectFailed": "无法连接站点访问服务,请重试",
+ "gate.expired": "站点访问已失效,请重新验证",
+ "gate.serviceUnavailable": "站点验证服务暂时不可用 ({status})",
+
+ "host.onlineCount": "{n} / {max} 人在线",
+ "host.notStarted": "尚未开始",
+ "host.startCancelled": "启动已取消",
+ "host.switchingSource": "正在切换来源",
+ "host.capture.fpsUnknown": "帧率未知",
+ "host.capture.codecPending": "编码待定",
+ "host.capture.hasAudio": "含音频",
+ "host.capture.noAudio": "无音频",
+ "host.stageAria": "分享或加入房间",
+ "host.captureAria": "实际捕获参数",
+ "host.quality.title": "{label} · {mbps} Mbps",
+ "host.audio.title": "{label} · {kbps} kbps 上限",
+ "host.roomExpired": "房间已过期",
+ "host.roomClosed": "房间已关闭",
+ "host.pause.noTracksResume": "当前分享没有可恢复的媒体轨道",
+ "host.pause.signalRecovering": "服务器连接正在恢复,分享仍保持暂停",
+ "host.pause.noTracksPause": "当前分享没有可暂停的媒体轨道",
+ "host.pause.stillPaused": "分享仍保持暂停",
+ "host.shareEnded": "当前分享已经结束",
+ "host.fail.start": "启动分享失败",
+ "host.err.createConnection": "创建连接失败",
+ "host.err.codecUnsupported": "当前浏览器无法使用支持的视频编码",
+ "host.err.applySender": "应用发送参数失败",
+ "host.err.applyAudioSender": "应用音频发送参数失败",
+ "host.fail.source": "切换分享来源失败",
+ "host.fail.quality": "应用画质设置失败",
+ "host.fail.connection": "观看连接处理失败",
+ "host.fail.room": "房间操作失败",
+ "host.err.invalidToken": "分享凭证已失效,请重新创建房间",
+ "host.err.accessDenied": "当前操作没有权限",
+ "host.err.roomExpired": "房间已过期,请重新创建",
+ "host.err.alreadyConnected": "此房间已在另一个页面中分享",
+ "host.err.peerGone": "对应的观看连接已经离开",
+ "host.err.forbidden": "当前操作不可用",
+ "host.err.serverError": "服务暂时不可用,请稍后重试",
+ "host.err.createRoomStatus": "当前无法创建房间 ({status})",
+ "host.err.replaceRoomStatus": "当前无法更换房间 ({status})",
+ "host.err.updateRoomStatus": "当前无法更新房间设置 ({status})",
+ "host.capture.cancelled": "屏幕选择已取消或没有共享权限",
+ "host.capture.noSource": "没有可用的屏幕分享来源",
+ "host.capture.readFailed": "浏览器暂时无法读取所选分享来源",
+ "host.capture.unavailable": "当前页面无法启动屏幕分享",
+ "host.notice.reconnecting": "部分观看者正在重新连接",
+ "host.notice.sfuRecovering": "SFU 分享来源未切换成功,正在恢复观看连接",
+ "host.password.inputPlaceholder": "输入密码",
+
+ "stats.warn.codec": "视频编码为 {codec},预期 H264 或 VP8",
+ "stats.warn.audioCodec": "音频编码为 {codec},预期 Opus",
+
+ "viewer.msg.joinUnavailable": "暂时无法加入房间",
+ "viewer.stageAria": "共享画面",
+
+ "host.warn.audioUnread": "浏览器未读回音频码率上限",
+ "host.warn.bandwidth": "当前连接带宽受限,画质已自动降低",
+ "host.warn.encoding": "编码性能受限,画质已自动降低",
+ "host.warn.other": "浏览器持续报告其他画质限制",
+ "host.warn.unclassified": "浏览器持续报告未分类的画质限制",
+ "host.warn.audioRewritten": "浏览器将音频码率上限改写为 {kbps} kbps",
+ "host.warn.senderPartial": "浏览器未完整接受{params}",
+ "host.warn.param.maxBitrate": "码率上限",
+ "host.warn.param.maxFramerate": "帧率上限",
+ "host.warn.param.scaleResolutionDownBy": "分辨率缩放",
+ "host.warn.param.degradationPreference": "质量优先级",
+ "host.warn.param.scalabilityMode": "伸缩模式",
+ "host.warn.sfuRecover": "SFU {stage}失败,已启动自动恢复",
+ "host.warn.sfuStage.connect": "连接",
+ "host.warn.sfuStage.source": "分享源",
+ "host.warn.sfuStage.videoPublish": "视频发布",
+ "host.warn.sfuStage.senderConfig": "视频参数配置",
+ "host.warn.sfuStage.audioPublish": "音频发布",
+ "host.warn.sfuStage.transport": "传输",
+ "host.fail.sfuSwitch": "切换 SFU 分享来源失败",
+ "host.fail.sfuAudioParams": "应用 SFU 音频发送参数失败",
+ "host.fail.sfuParams": "应用 SFU 发送参数失败",
+} as const;
+
+export type CopyKey = keyof typeof zh;
+
+export const zhTitleFrames = {
+ hostActive: [
+ zh["host.live"],
+ "屏幕已亮",
+ "像素出发",
+ "画面开跑",
+ "小电视上工",
+ "好戏开场",
+ "信号在路上",
+ "窗口营业中",
+ "这波有画面",
+ "像素在整活",
+ "游戏已开席",
+ "大幕拉开",
+ ],
+ viewerActive: [
+ zh["viewer.title.watching"],
+ "已经就座",
+ "像素到站",
+ "正在围观",
+ "爆米花就位",
+ "画面收到",
+ "小电视开工",
+ "沙发已占好",
+ "前方高能",
+ "奇文共欣赏",
+ "这波有画面",
+ "小板凳已搬好",
+ ],
+ paused: [zh["host.paused"]],
+ hostStarting: [zh["host.starting"], "正在搭线", "信号打招呼"],
+ hostEnded: [zh["host.ended"]],
+ hostReady: [
+ zh["host.roomReady"],
+ "沙发已摆好",
+ "随时可以开场",
+ "小电视待命",
+ "遥控器就位",
+ "灯光已调好",
+ "频道等你",
+ "茶水已备好",
+ ],
+ hostIdle: [
+ zh["host.notStarted"],
+ "小电视在休息",
+ "等一块新屏幕",
+ "天线在打盹",
+ "屏幕做个梦",
+ "遥控器在发呆",
+ "等一个开场",
+ "小客厅静悄悄",
+ ],
+ viewerWaiting: [
+ zh["viewer.title.waiting"],
+ "等待开场",
+ "爆米花准备中",
+ "小板凳已搬好",
+ "沙发留了位置",
+ "遥控器握好了",
+ "正在等画面",
+ "观众席待命",
+ ],
+} as const;
+
+export type TitleFrameKey = keyof typeof zhTitleFrames;
+export type TitleFrameCatalog = Record<
+ TitleFrameKey,
+ readonly [string, ...string[]]
+>;
diff --git a/src/client/pages/HostPage.tsx b/src/client/pages/HostPage.tsx
index 35b25439..1d0f05a5 100644
--- a/src/client/pages/HostPage.tsx
+++ b/src/client/pages/HostPage.tsx
@@ -28,6 +28,10 @@ import { useMetricsExpanded } from "../components/living/Metrics";
import { PawnDetail } from "../components/living/PawnDetail";
import { RoomChip } from "../components/living/RoomChip";
import { RouteTree } from "../components/living/RouteTree";
+import {
+ ViewerOverview,
+ type ViewerOverviewEntry,
+} from "../components/living/ViewerOverview";
import type { ComicKind } from "../components/living/Comic";
import { ComicTooltip } from "../components/living/ComicTooltip";
import type { HintKind } from "../components/living/hints";
@@ -68,8 +72,10 @@ import { createOpaqueId } from "../lib/opaque-id";
import {
defaultHostDisplayName,
readDisplayName,
+ readStoredDisplayName,
saveDisplayName,
} from "../lib/display-name";
+import { useDocumentTitle } from "../ui/document-title";
import {
clearHostRoom,
getStableClientId,
@@ -357,6 +363,7 @@ interface HostPageProps {
}
export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
+ const { lang, vis, t, titleFrames } = useCopy();
const [qualitySettings, setQualitySettings] = useState<QualitySettings>(
DEFAULT_QUALITY_SETTINGS,
);
@@ -407,7 +414,12 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
const [participantPresence, setParticipantPresence] = useState<
ParticipantPresenceEntry[]
>([]);
- const [displayName, setDisplayName] = useState(() => readDisplayName());
+ const [hasCustomDisplayName, setHasCustomDisplayName] = useState(
+ () => readStoredDisplayName() !== null,
+ );
+ const [displayName, setDisplayName] = useState(() =>
+ readDisplayName(defaultHostDisplayName("", vis)),
+ );
const [displayNameDraft, setDisplayNameDraft] = useState(displayName);
const [displayNameError, setDisplayNameError] = useState<string | null>(null);
const [editingDisplayName, setEditingDisplayName] = useState(false);
@@ -444,7 +456,6 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
const [showConnectionDetails, setShowConnectionDetails] = useState(false);
const [showTopology, setShowTopology] = useState(false);
const [joiningRoom, setJoiningRoom] = useState(false);
- const { vis, t } = useCopy();
const [selectedPawn, setSelectedPawn] = useState<string | null>(null);
const [joinRoomCode, setJoinRoomCode] = useState("");
const [joinRoomError, setJoinRoomError] = useState(false);
@@ -457,6 +468,18 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
const signalRef = useRef<SignalingClient | null>(null);
const displayNameRef = useRef(displayName);
const hostClientIdRef = useRef<string | null>(null);
+ useEffect(() => {
+ if (hasCustomDisplayName) return;
+ const fallback = defaultHostDisplayName(
+ hostClientIdRef.current ?? "",
+ vis,
+ );
+ if (displayNameRef.current === fallback) return;
+ displayNameRef.current = fallback;
+ setDisplayName(fallback);
+ if (!editingDisplayName) setDisplayNameDraft(fallback);
+ signalRef.current?.setDisplayName(fallback);
+ }, [hasCustomDisplayName, lang, vis]);
const iceConfigRef = useRef<IceConfig | null>(null);
const peersRef = useRef(new Map<string, HostPeer>());
const hostProvisionalChildRef = useRef<HostProvisionalChild | null>(null);
@@ -1891,7 +1914,7 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
let authenticated = false;
const hostClientId = getStableClientId("host", activeRoom.roomId);
hostClientIdRef.current = hostClientId;
- const hostFallback = defaultHostDisplayName(hostClientId);
+ const hostFallback = defaultHostDisplayName(hostClientId, vis);
const initialDisplayName = readDisplayName(hostFallback);
displayNameRef.current = initialDisplayName;
setDisplayName(initialDisplayName);
@@ -2397,8 +2420,8 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
function commitDisplayName(): void {
const hostFallback = hostClientIdRef.current
- ? defaultHostDisplayName(hostClientIdRef.current)
- : defaultHostDisplayName("");
+ ? defaultHostDisplayName(hostClientIdRef.current, vis)
+ : defaultHostDisplayName("", vis);
const saved = saveDisplayName(displayNameDraft, hostFallback);
if (!saved) {
setDisplayNameError(say("host.nameError"));
@@ -2409,6 +2432,7 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
setDisplayNameDraft(saved);
setDisplayNameError(null);
setEditingDisplayName(false);
+ setHasCustomDisplayName(readStoredDisplayName() !== null);
if (!signalRef.current?.setDisplayName(saved)) {
setNoticeKey("host.nameOffline");
}
@@ -2458,32 +2482,26 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
};
});
- const selectedViewer = selectedPawn
- ? (viewers.find((viewer) => viewer.peerId === selectedPawn) ?? null)
- : null;
- let selectedDetail: {
+ type ViewerDetail = {
route: "p2p" | "sfu" | null;
metrics: ConnectionMetrics | null;
direction: "send" | "receive";
tag?: { icon: "loader"; label: string };
error: string | null;
- } | null = null;
- if (selectedViewer) {
+ };
+ const detailForViewer = (viewer: (typeof viewers)[number]): ViewerDetail => {
const snapshot =
- selectedViewer.upstream.kind === "peer" &&
- selectedViewer.upstream.peerId === hostPeerId
- ? peerSnapshots.get(selectedViewer.peerId)
+ viewer.upstream.kind === "peer" && viewer.upstream.peerId === hostPeerId
+ ? peerSnapshots.get(viewer.peerId)
: undefined;
- const qualityPresentation = viewerQualityEvidence.get(
- selectedViewer.peerId,
- );
+ const qualityPresentation = viewerQualityEvidence.get(viewer.peerId);
const qualityEvidence = qualityPresentation?.evidence;
const hasMatchingQualityEvidence =
qualityEvidence !== undefined &&
- qualityEvidenceUpstreamMatches(qualityEvidence, selectedViewer.upstream);
+ qualityEvidenceUpstreamMatches(qualityEvidence, viewer.upstream);
const hasCurrentQualityEvidence =
hasMatchingQualityEvidence && qualityPresentation?.fresh === true;
- const hasCommittedMedia = selectedViewer.mediaReady === true;
+ const hasCommittedMedia = viewer.mediaReady === true;
const hasCurrentRouteEvidence =
hasPeerRouteEvidence(snapshot) ||
hasCurrentQualityEvidence ||
@@ -2500,10 +2518,10 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
: snapshot && hasPeerRouteEvidence(snapshot)
? snapshot.metrics
: null;
- selectedDetail = {
+ return {
route:
- hasCurrentRouteEvidence && selectedViewer.upstream.kind !== "none"
- ? selectedViewer.upstream.kind === "peer"
+ hasCurrentRouteEvidence && viewer.upstream.kind !== "none"
+ ? viewer.upstream.kind === "peer"
? "p2p"
: "sfu"
: null,
@@ -2519,7 +2537,27 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
},
error: snapshot?.error ?? null,
};
- }
+ };
+ const viewerDetails = new Map(
+ viewers.map((viewer) => [viewer.peerId, detailForViewer(viewer)] as const),
+ );
+ const selectedViewer = selectedPawn
+ ? (viewers.find((viewer) => viewer.peerId === selectedPawn) ?? null)
+ : null;
+ const selectedDetail = selectedViewer
+ ? (viewerDetails.get(selectedViewer.peerId) ?? null)
+ : null;
+ const viewerOverviewEntries: ViewerOverviewEntry[] = couchEntries.map(
+ (entry) => {
+ const detail = viewerDetails.get(entry.key);
+ return {
+ ...entry,
+ statusLabel: entry.statusLabel ?? t("state.peer.connecting"),
+ route: detail?.route ?? null,
+ metrics: detail?.metrics ?? null,
+ };
+ },
+ );
const noticeText = noticeValue
? noticeValue.kind === "text"
@@ -2540,6 +2578,20 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
: room
? t("host.roomReady")
: t("host.notStarted");
+ const titleFrameKey =
+ phase === "live"
+ ? sharingPaused
+ ? "paused"
+ : "hostActive"
+ : phase === "starting"
+ ? "hostStarting"
+ : phase === "ended"
+ ? "hostEnded"
+ : room
+ ? "hostReady"
+ : "hostIdle";
+ const titleContent = titleFrames(titleFrameKey);
+ useDocumentTitle([room?.roomId, titleContent[0]], titleContent.slice(1));
// Vis mode swaps native title tooltips for 2-panel hint comics; text modes
// render the trigger unchanged, so markup structure stays identical.
@@ -2773,6 +2825,17 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
</div>
<div className="lr-deck">
+ {showConnectionDetails && viewerOverviewEntries.length > 0 ? (
+ <ViewerOverview
+ entries={viewerOverviewEntries}
+ selectedKey={selectedPawn}
+ onSelect={(peerId) =>
+ setSelectedPawn((current) =>
+ current === peerId ? null : peerId,
+ )
+ }
+ />
+ ) : null}
{selectedViewer && selectedDetail ? (
<PawnDetail
pawnKey={selectedViewer.peerId}
@@ -3525,8 +3588,8 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
title={showConnectionDetails ? "host.details.hide" : "host.details"}
tone={showConnectionDetails ? "on" : undefined}
expanded={showConnectionDetails}
- controls="host-details-panel"
- disabled={!details || !stream}
+ controls="host-details-panel host-viewer-overview"
+ disabled={(!details || !stream) && viewers.length === 0}
onClick={() => setShowConnectionDetails((current) => !current)}
/>,
"start",
@@ -3647,6 +3710,11 @@ export function HostPage({ onAuthorizationRequired }: HostPageProps = {}) {
hostLabel={labeledHostPresence?.label ?? displayName}
viewers={viewers}
selectedPeerId={selectedPawn}
+ onSelectPeer={(peerId) =>
+ setSelectedPawn((current) =>
+ current === peerId ? null : peerId,
+ )
+ }
/>
</Row>
) : null}
diff --git a/src/client/pages/ViewerPage.tsx b/src/client/pages/ViewerPage.tsx
index 4e30d171..6275d4d8 100644
--- a/src/client/pages/ViewerPage.tsx
+++ b/src/client/pages/ViewerPage.tsx
@@ -47,7 +47,13 @@ import {
} from "../components/living/primitives";
import { Glyph, type GlyphName } from "../ui/icons";
import { useCopy, type CopyKey } from "../ui/copy";
-import { readDisplayName, saveDisplayName } from "../lib/display-name";
+import {
+ defaultViewerDisplayName,
+ readDisplayName,
+ readStoredDisplayName,
+ saveDisplayName,
+} from "../lib/display-name";
+import { useDocumentTitle } from "../ui/document-title";
import { clearViewerGrant, getStableClientId } from "../lib/session";
import { SignalingClient } from "../lib/signaling";
import { labelParticipantSnapshot } from "../lib/viewer-presence";
@@ -231,7 +237,11 @@ function MeterTag({ icon, label }: { icon: GlyphName; label: string }) {
}
export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
- const { t, vis } = useCopy();
+ const { lang, t, vis, titleFrames } = useCopy();
+ const viewerClientId = useMemo(
+ () => getStableClientId("viewer", roomId),
+ [roomId],
+ );
const [presentationState, dispatchPresentationState] = useReducer(
reduceViewerPresentation,
INITIAL_VIEWER_PRESENTATION_STATE,
@@ -254,7 +264,13 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
useState<ViewerQualityEvidencePresentation | null>(null);
const [showConnectionDetails, setShowConnectionDetails] = useState(false);
const [showTopology, setShowTopology] = useState(false);
- const [displayName, setDisplayName] = useState(() => readDisplayName());
+ const [theaterMode, setTheaterMode] = useState(false);
+ const [hasCustomDisplayName, setHasCustomDisplayName] = useState(
+ () => readStoredDisplayName() !== null,
+ );
+ const [displayName, setDisplayName] = useState(() =>
+ readDisplayName(defaultViewerDisplayName(viewerClientId, vis)),
+ );
const [displayNameDraft, setDisplayNameDraft] = useState(displayName);
const [displayNameError, setDisplayNameError] = useState(false);
const [editingDisplayName, setEditingDisplayName] = useState(false);
@@ -281,6 +297,19 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
useMetricsExpanded();
const [pawnMetricsExpanded, setPawnMetricsExpanded] = useMetricsExpanded();
+ useEffect(() => {
+ if (!theaterMode) return;
+ const exitOnEscape = (event: KeyboardEvent) => {
+ if (event.key === "Escape") setTheaterMode(false);
+ };
+ document.body.classList.add("lr-theater-open");
+ window.addEventListener("keydown", exitOnEscape);
+ return () => {
+ document.body.classList.remove("lr-theater-open");
+ window.removeEventListener("keydown", exitOnEscape);
+ };
+ }, [theaterMode]);
+
const qualityLimitation = useMemo(
() =>
qualityLimitationSummary(
@@ -295,6 +324,20 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
[participantPresence],
);
const hostDisplayName = labeledHostPresence?.label ?? null;
+ const titleFrameKey =
+ presentationState.host === "paused"
+ ? "paused"
+ : presentation.hasCurrentFrame
+ ? "viewerActive"
+ : "viewerWaiting";
+ const titleContent = titleFrames(titleFrameKey);
+ useDocumentTitle(
+ [
+ accessState === "ready" ? roomId : null,
+ accessState === "ready" ? titleContent[0] : null,
+ ],
+ accessState === "ready" ? titleContent.slice(1) : [],
+ );
function clearParticipantPresence(): void {
setParticipantPresence(null);
@@ -323,6 +366,15 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
useRef<ViewerQualityEvidenceReporter | null>(null);
const qualityFrameProofGenerationRef = useRef<number | null>(null);
const displayNameRef = useRef(displayName);
+ useEffect(() => {
+ if (hasCustomDisplayName) return;
+ const fallback = defaultViewerDisplayName(viewerClientId, vis);
+ if (displayNameRef.current === fallback) return;
+ displayNameRef.current = fallback;
+ setDisplayName(fallback);
+ if (!editingDisplayName) setDisplayNameDraft(fallback);
+ signalRef.current?.setViewerDisplayName(fallback);
+ }, [hasCustomDisplayName, lang, vis, viewerClientId]);
const remoteMediaRef = useRef<RemoteMediaBinding | null>(null);
const mediaGenerationRef = useRef(0);
const hostPlaybackPauseRef = useRef({ active: false, resume: false });
@@ -557,7 +609,7 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
{
roomId,
role: "viewer",
- clientId: getStableClientId("viewer", roomId),
+ clientId: viewerClientId,
...(viewerGrant ? { viewerGrant } : {}),
...(!viewerGrant && viewerPasswordAttempt
? { viewerPassword: viewerPasswordAttempt.password }
@@ -1999,7 +2051,8 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
}
function commitDisplayName(): void {
- const saved = saveDisplayName(displayNameDraft);
+ const fallback = defaultViewerDisplayName(viewerClientId, vis);
+ const saved = saveDisplayName(displayNameDraft, fallback);
if (!saved) {
setDisplayNameError(true);
return;
@@ -2009,6 +2062,7 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
setDisplayNameDraft(saved);
setDisplayNameError(false);
setEditingDisplayName(false);
+ setHasCustomDisplayName(readStoredDisplayName() !== null);
signalRef.current?.setViewerDisplayName(saved);
}
@@ -2225,10 +2279,17 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
: "state.peer.connecting",
),
you: isSelf,
- child: isChild,
- selectable: isSelf || isChild ? undefined : false,
+ selectable: isChild ? undefined : false,
};
});
+ const selectableRelayChildren = viewers
+ .filter(
+ (viewer) =>
+ selfPeerId !== null &&
+ viewer.upstream.kind === "peer" &&
+ viewer.upstream.peerId === selfPeerId,
+ )
+ .map((viewer) => viewer.peerId);
// Vis mode swaps native title tooltips for 2-panel hint comics; text modes
// render the trigger unchanged, so markup structure stays identical. Edge
@@ -2257,13 +2318,13 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
<AppHeader
led={<LedStrip state={ledState} label={t(presentation.messageKey)} />}
/>
- <main className="lr-room">
+ <main className={`lr-room${theaterMode ? " is-theater" : ""}`}>
<h1 className="visually-hidden">
{hostDisplayName
? t("viewer.title", { name: hostDisplayName })
: t("viewer.titleFallback")}
</h1>
- <div className="lr-scene">
+ <div className="lr-scene" id="viewer-stage">
<StageTv
chin={chin}
live={presentation.stage === "playing"}
@@ -2329,6 +2390,16 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
/>
)}
</StageTv>
+ {theaterMode ? (
+ <div className="lr-theater-exit">
+ <Btn
+ icon="contract"
+ cap="viewer.theater.exit"
+ title="viewer.theater.exit"
+ onClick={() => setTheaterMode(false)}
+ />
+ </div>
+ ) : null}
<div className="lr-shelf" aria-hidden="true" />
<Couch
entries={couchEntries}
@@ -2339,20 +2410,6 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
/>
</div>
<div className="lr-deck">
- {selectedPawn !== null &&
- selectedPawn === selfPeerId ? (
- <PawnDetail
- pawnKey={selectedPawn}
- name={vis ? displayName : `${displayName} · ${t("common.you")}`}
- you
- route={routePresentation.route}
- metrics={routeMetrics}
- direction="receive"
- expanded={pawnMetricsExpanded}
- onToggleMetrics={setPawnMetricsExpanded}
- onClose={() => setSelectedPawn(null)}
- />
- ) : null}
{selectedPawn !== null && selectedChildEvidence ? (
<PawnDetail
pawnKey={selectedPawn}
@@ -2452,6 +2509,15 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
)}
</form>
<div className="lr-row-group lr-group-actions lr-viewer-actions-slot">
+ <Btn
+ icon={theaterMode ? "contract" : "expand"}
+ cap={theaterMode ? "viewer.theater.exit" : "viewer.theater"}
+ title={theaterMode ? "viewer.theater.exit" : "viewer.theater"}
+ tone={theaterMode ? "on" : undefined}
+ pressed={theaterMode}
+ controls="viewer-stage"
+ onClick={() => setTheaterMode((current) => !current)}
+ />
{labeledHostPresence
? hintWrap(
"hint-topology",
@@ -2556,6 +2622,12 @@ export function ViewerPage({ roomId, viewerGrant }: ViewerPageProps) {
viewers={viewers}
selfPeerId={selfPeerId}
selectedPeerId={selectedPawn}
+ selectablePeerIds={selectableRelayChildren}
+ onSelectPeer={(peerId) =>
+ setSelectedPawn((current) =>
+ current === peerId ? null : peerId,
+ )
+ }
/>
</Row>
) : null}
diff --git a/src/client/styles.css b/src/client/styles.css
index 144d5783..0f30037a 100644
--- a/src/client/styles.css
+++ b/src/client/styles.css
@@ -312,17 +312,61 @@ html[data-theme="dark"] .lr-brand-sparkles { stroke: #f4c14d; }
padding: 8px clamp(14px, 3.5vw, 40px) 64px;
}
.lr-scene { position: relative; min-width: 0; }
+body.lr-theater-open { overflow: hidden; }
+.lr-room.is-theater {
+ position: fixed;
+ z-index: 1000;
+ inset: 0;
+ width: 100vw;
+ height: 100dvh;
+ padding: 0;
+ background: var(--stage);
+}
+.lr-room.is-theater .lr-scene { width: 100%; height: 100%; }
+.lr-room.is-theater .lr-tv {
+ width: 100%;
+ height: 100%;
+ padding: 0;
+ border: 0;
+ border-radius: 0;
+}
+.lr-room.is-theater .lr-tv-screen,
+.lr-room.is-theater .lr-tv-screen.has-entry {
+ width: 100%;
+ height: 100%;
+ min-height: 0;
+ overflow: hidden;
+ aspect-ratio: auto;
+ border-radius: 0;
+}
+.lr-room.is-theater .lr-tv-chin,
+.lr-room.is-theater .lr-shelf,
+.lr-room.is-theater .lr-couch,
+.lr-room.is-theater .lr-deck { display: none; }
+.lr-theater-exit {
+ position: absolute;
+ z-index: 3;
+ top: max(14px, env(safe-area-inset-top));
+ right: max(14px, env(safe-area-inset-right));
+}
+.lr-theater-exit .lr-btn {
+ border-color: rgba(223, 232, 242, .82);
+ background: rgba(10, 16, 28, .72);
+ color: #fff;
+ backdrop-filter: blur(8px);
+}
/* ---------- the TV ---------- */
.lr-tv {
position: relative;
- width: min(880px, 100%);
+ width: min(960px, 100%);
margin: 0 auto;
padding: 12px 12px 0;
border: 3px solid var(--frame);
border-radius: 26px 26px 20px 20px;
background: var(--frame);
+ transition: width 240ms var(--spring);
}
.lr-tv-screen {
position: relative;
@@ -467,7 +511,7 @@ html[data-theme="dark"] .lr-brand-sparkles { stroke: #f4c14d; }
.lr-couch {
position: relative;
width: min(720px, 96%);
- margin: 22px auto 0;
+ margin: 34px auto 0;
}
.lr-couch > svg { display: block; width: 100%; height: auto; }
.lr-pawns-window {
@@ -533,8 +577,6 @@ html[data-theme="dark"] .lr-brand-sparkles { stroke: #f4c14d; }
border: 2.5px solid var(--action);
border-radius: 13px;
}
-.lr-pawn.is-child { min-width: 34px; align-self: end; }
-.lr-pawn.is-child svg { width: 30px; height: 36px; }
.lr-pawns.is-crowded { gap: 6px; }
.lr-pawns.is-crowded .lr-pawn { min-width: 33px; }
.lr-pawns.is-crowded .lr-pawn svg { width: 29px; height: 35px; }
@@ -550,7 +592,6 @@ html[data-theme="dark"] .lr-brand-sparkles { stroke: #f4c14d; }
white-space: nowrap;
box-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}
-.lr-pawn-name.is-mini { font-size: 9px; padding: 0 5px; }
.lr-couch-count {
position: absolute;
right: 4%;
@@ -631,10 +672,11 @@ html[data-theme="dark"] .lr-viewer-host-slot svg { color: #9bb0c5; }
flex: 0 1 auto;
align-items: center;
gap: 8px;
+ margin-left: auto;
}
.lr-viewer-actions-slot {
flex: 0 0 auto;
- margin-left: auto;
+ margin-left: 0;
}
.lr-viewer-self-slot .lr-name-tag { flex: 0 1 auto; width: auto; }
.lr-spacer { flex: 1; }
@@ -1016,8 +1058,108 @@ html[data-theme="dark"] .lr-meter-cell svg { color: #7d92a8; }
.lr-route-label.is-sfu { fill: var(--route-sfu); font-weight: 800; opacity: 1; }
.lr-route-label.is-recovering { fill: var(--route-pending); opacity: 1; }
.lr-route-label.is-selected { fill: var(--action-deep); font-weight: 800; opacity: 1; }
+.lr-route-hit {
+ fill: transparent;
+ stroke: transparent;
+ stroke-width: 2px;
+ cursor: pointer;
+ transition: stroke 140ms ease, fill 140ms ease;
+}
+.lr-route-hit:hover,
+.lr-route-hit:focus-visible {
+ fill: color-mix(in srgb, var(--action) 8%, transparent);
+ stroke: color-mix(in srgb, var(--action) 50%, transparent);
+ outline: none;
+}
@keyframes lr-flow { to { stroke-dashoffset: -24; } }
+/* Dense Host overview: one aligned row per Viewer, not a card wall. */
+.lr-viewer-overview {
+ width: 100%;
+ min-width: 0;
+}
+.lr-viewer-overview-scroll {
+ overflow-x: auto;
+ border: 2.5px solid var(--ink);
+ border-radius: var(--radius);
+ background: var(--paper);
+ scrollbar-color: var(--route-sfu) transparent;
+ scrollbar-width: thin;
+}
+.lr-viewer-overview-head,
+.lr-viewer-overview-row {
+ display: grid;
+ min-width: 820px;
+ grid-template-columns: minmax(170px, 1.5fr) 76px 116px 78px 98px 88px 76px;
+ align-items: center;
+ gap: 10px;
+ padding: 8px 12px;
+}
+.lr-viewer-overview-head {
+ color: #53676a;
+ background: var(--wall-2);
+ font-size: 10px;
+ font-weight: 750;
+ text-transform: uppercase;
+}
+.lr-viewer-overview-head > span:not(:first-child),
+.lr-viewer-overview-row > span:not(:first-child) { text-align: center; }
+.lr-viewer-overview-row {
+ width: 100%;
+ border: 0;
+ border-top: 1.5px solid var(--wall-2);
+ background: transparent;
+ color: var(--ink);
+ font-family: var(--mono);
+ font-size: 11px;
+ transition: background 140ms ease, color 140ms ease;
+}
+.lr-viewer-overview-row:hover { background: color-mix(in srgb, var(--action) 7%, transparent); }
+.lr-viewer-overview-row.is-selected { background: color-mix(in srgb, var(--action) 14%, transparent); }
+.lr-viewer-overview-row:focus-visible { outline: 3px solid var(--action); outline-offset: -3px; }
+.lr-viewer-overview-person {
+ display: flex;
+ min-width: 0;
+ align-items: center;
+ gap: 8px;
+ text-align: left;
+}
+.lr-viewer-overview-person-copy {
+ display: grid;
+ min-width: 0;
+ line-height: 1.15;
+ text-align: left;
+}
+.lr-viewer-overview-person-copy > b {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.lr-viewer-overview-person-copy > small { font-size: 9px; font-weight: 600; opacity: .58; }
+.lr-viewer-overview-pawn { position: relative; flex: 0 0 auto; }
+.lr-viewer-overview-pawn svg { display: block; width: 24px; height: 29px; }
+.lr-viewer-overview-pawn i {
+ position: absolute;
+ top: 0;
+ right: -2px;
+ width: 7px;
+ height: 7px;
+ border: 1.5px solid var(--paper);
+ border-radius: 50%;
+ background: var(--live);
+}
+.lr-viewer-overview-pawn i.is-wait { background: var(--warn); }
+.lr-viewer-overview-route {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 4px;
+}
+.lr-viewer-overview-route.is-p2p { color: var(--route-p2p); }
+.lr-viewer-overview-route.is-sfu { color: var(--route-sfu); }
+.lr-viewer-overview-route.is-pending { color: var(--route-pending); }
+
/* ---------- advanced door ---------- */
.lr-door-body {
@@ -1191,7 +1333,7 @@ html[data-theme="dark"] .lr-switch::after { background: var(--ink); }
.lr-viewer-summary-row .lr-row-group { width: auto; }
.lr-viewer-host-slot { flex: 0 1 auto; max-width: 180px; }
.lr-viewer-state-slot { flex: 1 1 120px; }
- .lr-viewer-self-slot { flex: 1 1 auto; gap: 6px; }
+ .lr-viewer-self-slot { flex: 1 1 auto; gap: 6px; margin-left: 0; }
.lr-viewer-actions-slot { flex: 1 1 100%; margin-left: 0; }
.lr-input.lr-name-editor { width: min(136px, 40vw); }
.lr-group-actions { display: flex; width: 100%; gap: 8px; min-width: 0; }
diff --git a/src/client/ui/copy.ts b/src/client/ui/copy.ts
index e88a5d4f..cb1dd4f3 100644
--- a/src/client/ui/copy.ts
+++ b/src/client/ui/copy.ts
@@ -1,714 +1,17 @@
-// The single copy catalog. zh and en carry identical keys (type-enforced);
-// "visual" is a presentation mode over the same keys, not another catalog.
-//
-// Store notes: lang/vis sync across tabs via the window "storage" event (a
-// commit in one tab re-applies the persisted values here; theme.ts keeps its
-// own per-tab store). Known trade-off: flipping lang/vis while a hint tooltip
-// is open remounts the trigger, because the living primitives mount
-// ComicTooltip conditionally, so keyboard focus drops to <body> on a mode
-// flip. The wrapper lives outside this module; the behavior is documented
-// here where the flip originates.
+// Locale selection and persistence. Catalog content lives in ../locales.
import { useSyncExternalStore } from "react";
-
-export type Lang = "zh" | "en";
+import {
+ catalogs,
+ titleFrameCatalogs,
+ visualTitleFrames,
+ type CopyKey,
+ type Lang,
+ type TitleFrameKey,
+} from "../locales";
+
+export type { CopyKey, Lang, TitleFrameKey } from "../locales";
export type CopyMode = "text" | "vis";
-const zh = {
- "brand.home": "Screener 首页",
-
- "common.roomCode": "房间号",
- "common.copy": "复制",
- "common.copied": "已复制",
- "common.copyFailed": "复制失败",
- "common.cancel": "取消",
- "common.retry": "重试",
- "common.refresh": "刷新页面",
- "common.edit": "编辑",
- "common.close": "收起",
- "common.viewers": "观看者",
- "common.you": "你",
- "common.host": "分享者",
- "common.name.viewerDefault": "访客",
- "common.name.hostDefault": "分享者",
-
- "gate.title": "站点访问",
- "gate.hint": "请输入站点口令",
- "gate.password": "站点口令",
- "gate.submit": "进入站点",
- "gate.checking": "正在验证站点访问",
- "gate.wrong": "站点口令不正确,请重试",
- "gate.unavailable": "暂时无法验证站点访问",
- "gate.malformed": "房间号格式不正确",
- "gate.malformedHint": "请输入 1000 至 9999 的四位房间号",
- "gate.unavailableRoute": "无法访问",
-
- "join.title": "加入房间",
- "join.hint": "输入分享者提供的房间号",
- "join.field": "房间号",
- "join.submit": "加入",
- "join.invalid": "请输入 1000 至 9999 的四位房间号",
- "join.joining": "正在加入房间",
- "join.notFound": "房间不存在或已过期",
- "join.notFoundHint": "请确认房间号,或向分享者获取新的邀请链接。",
- "join.denied": "当前无法通过房间号加入",
- "join.deniedHint": "请使用分享者提供的邀请链接,或尝试房间密码。",
- "join.password": "房间密码",
- "join.passwordError": "无法加入房间,请重试",
- "join.passwordRule": "请输入 1-{max} 个可见字符",
- "join.passwordAction": "输入房间密码",
- "join.full": "房间已满",
-
- "host.title": "{name} 的屏幕",
- "host.idle.heading": "想播点什么?",
- "host.idle.hint": "分享你的屏幕,朋友凭房间号或邀请链接就能进来看。",
- "host.start": "开始分享",
- "host.join": "加入房间",
- "host.starting": "正在连接",
- "host.cancelStart": "取消",
- "host.live": "正在分享",
- "host.paused": "已暂停",
- "host.ended": "已停止分享",
- "host.roomReady": "房间已就绪",
- "host.pause": "暂停分享",
- "host.resume": "恢复分享",
- "host.switchSource": "切换来源",
- "host.switching": "正在选择",
- "host.stop": "停止分享",
- "host.noAudio": "当前来源没有可共享音频",
- "host.localPreviewPaused": "本地预览已暂停,分享仍在继续",
- "host.pauseNotice": "音视频分享已暂停",
- "host.resumeNotice": "音视频分享已恢复",
- "host.stopNotice": "已停止分享",
- "host.roomReplaced": "房间号已更换",
- "host.roomInvalid": "房间已失效,再次点击将创建新房",
- "host.roomReplace": "更换房间号",
- "host.roomReplaceConfirm": "确认更换房间号",
- "host.captureError": "无法开始屏幕采集,请检查浏览器权限后重试",
- "host.terminated.stale": "页面版本已更新,请刷新后重试",
- "host.terminated.session": "此页面的会话已被另一个标签页接管",
- "host.terminated.signal": "服务器连接已终止,请刷新后重试",
- "host.notice.qualityApplied": "分享设置已应用",
- "host.notice.qualitySet": "画质已切换为 {label}",
- "host.notice.audioSet": "音频质量已切换为 {label}",
- "host.notice.partialApply": "分享设置已更新,但部分观看连接未能应用新参数",
- "host.notice.sourceSwitch.ok": "分享来源已切换",
- "host.notice.sourceSwitch.partial": "分享来源已切换,但{warning}",
-
- "host.name": "昵称",
- "host.nameSave": "保存昵称",
- "host.nameCancel": "取消编辑昵称",
- "host.nameEdit": "编辑昵称",
- "host.nameError": "名称格式无效或超过 24 个字符",
- "host.nameOffline": "开始分享并连接后才能修改昵称",
-
- "host.invite": "邀请链接",
- "host.invite.copy": "复制邀请链接",
- "host.invite.copyFailed": "无法复制邀请链接,请稍后重试",
- "host.invite.rotate": "更新邀请链接",
- "host.invite.revoke": "撤销邀请链接",
- "host.invite.rotateShort": "更新链接",
- "host.invite.revokeShort": "撤销链接",
- "host.invite.updated": "邀请链接已更新",
- "host.invite.revoked": "邀请链接已撤销",
- "host.invite.emptyOpen": "暂无邀请链接,仍可凭房间号加入",
- "host.invite.emptyPassword": "暂无邀请链接,仍可凭房间号和密码加入",
- "host.invite.emptyPrivate": "暂无邀请链接,请先更新链接再邀请他人",
-
- "host.policy": "准入方式",
- "host.policy.open": "公开",
- "host.policy.private": "私密",
- "host.policy.openHint": "知道房间号即可加入",
- "host.policy.privateHint": "凭邀请链接加入,或设置房间密码",
- "host.policy.setOpen": "房间已设为公开",
- "host.policy.setPrivateInvite": "房间已设为私密,仅限邀请加入",
- "host.policy.setPrivatePassword": "房间已设为私密,可凭邀请或密码加入",
- "host.password.set": "房间密码已设置",
- "host.password.unset": "房间密码未设置",
- "host.password.placeholder": "设置后可凭房间号加入",
- "host.password.setAction": "设置房间密码",
- "host.password.changeAction": "更改房间密码",
- "host.password.remove": "移除房间密码",
- "host.password.show": "显示房间密码",
- "host.password.hide": "隐藏房间密码",
- "host.password.saved": "房间密码已设置",
- "host.password.updated": "房间密码已更新",
- "host.password.removed": "房间密码已移除,仅限邀请加入",
- "host.password.rule": "房间密码只需 1-{max} 个可见字符",
- "host.accessFailed": "当前无法更新房间设置,请稍后重试",
-
- "host.viewers.empty": "暂无观看者",
- "host.viewers.waiting": "等待朋友加入",
-
- "host.quality": "视频预设",
- "host.quality.720p30": "720p · 30 帧",
- "host.quality.1080p30": "1080p · 30 帧",
- "host.quality.1080p60": "1080p · 60 帧",
- "host.advanced": "高级设置",
- "host.advanced.resolution": "分辨率上限",
- "host.advanced.framerate": "帧率上限",
- "host.advanced.bitrate": "视频码率上限",
- "host.advanced.preference": "画面偏好",
- "host.advanced.preference.resolution": "清晰",
- "host.advanced.preference.balanced": "均衡",
- "host.advanced.preference.framerate": "流畅",
- "host.advanced.preference.resolutionHint": "保留细节",
- "host.advanced.preference.balancedHint": "自动权衡",
- "host.advanced.preference.framerateHint": "优先帧率",
- "host.advanced.audio": "音频质量",
- "host.advanced.audio.saver": "普通",
- "host.advanced.audio.music": "音乐",
- "host.advanced.audio.veryHigh": "保真",
- "host.advanced.route": "路由策略",
- "host.advanced.route.topo": "自动优化拓扑",
- "host.advanced.route.topoHint": "观看中逐步选择更健康的连接",
- "host.advanced.route.peerOnly": "纯 P2P",
- "host.advanced.route.peerOnlyHint": "不使用媒体服务器,无法直连时停止尝试",
- "host.advanced.codec": "视频编码",
- "host.advanced.codec.auto": "自动",
- "host.advanced.codec.autoHint": "自动选择",
- "host.advanced.codec.vp8Hint": "兼容优先",
- "host.advanced.codec.h264Hint": "硬件优先",
-
- "host.details": "显示连接详情",
- "host.details.hide": "隐藏连接详情",
- "host.topology": "连接拓扑",
- "host.topology.show": "显示连接拓扑",
- "host.topology.hide": "隐藏连接拓扑",
- "host.topology.pending": "连接中",
- "host.sfu": "媒体服务器",
-
- "state.signal.connected": "服务器已连接",
- "state.signal.connecting": "正在连接",
- "state.signal.reconnecting": "正在恢复",
- "state.signal.offline": "服务器未连接",
- "state.peer.connected": "已连接",
- "state.peer.connecting": "正在连接",
- "state.peer.routing": "线路分配中",
- "state.peer.waiting": "等待开始分享",
- "state.peer.reconnecting": "正在恢复",
- "state.peer.failed": "连接失败",
- "state.peer.disconnected": "连接中断",
- "state.peer.closed": "已关闭",
- "state.peer.new": "准备中",
- "state.route.p2p": "P2P 直连",
- "state.route.sfu": "服务器中转",
-
- "stats.title": "连接数据",
- "stats.relay": "转发数据",
- "stats.downstream": "下游接收数据",
- "stats.more": "详细指标",
- "stats.less": "收起详细指标",
- "stats.resolution": "分辨率",
- "stats.fps": "帧率",
- "stats.bitrate": "码率",
- "stats.loss": "丢包率",
- "stats.rtt": "RTT",
- "stats.codec": "视频编码",
- "stats.jitter": "网络抖动",
- "stats.dropped": "丢帧",
- "stats.encoder": "编码器",
- "stats.audio": "音频码率",
- "stats.unknown": "未知",
- "stats.outgoing": "可用上行",
- "stats.qualityState": "质量状态",
- "stats.quality.normal": "正常",
- "stats.quality.bandwidth": "带宽受限",
- "stats.quality.cpu": "编码受限",
- "stats.quality.other": "其他限制",
- "stats.quality.unclassified": "未分类限制",
- "stats.capture": "捕获设置",
- "stats.inputFps": "编码输入帧率",
- "stats.encodeMs": "编码耗时/帧",
- "stats.decodeMs": "解码耗时/帧",
- "stats.freezeCount": "画面冻结",
- "stats.freezeDuration": "冻结时长",
- "stats.audioLoss": "音频丢包率",
- "stats.audioJitter": "音频抖动",
- "stats.playoutDelta": "音视频播放差",
- "stats.videoBuffer": "视频缓冲",
- "stats.audioBuffer": "音频缓冲",
- "stats.audioConcealedRate": "音频补偿率",
- "stats.audioConcealed": "音频补偿",
-
- "viewer.title": "{name} 的屏幕",
- "viewer.titleFallback": "好友屏幕",
- "viewer.reconnect": "重新连接媒体",
- "viewer.msg.joining": "正在加入房间",
- "viewer.msg.waitingHost": "等待开始分享",
- "viewer.msg.preparingP2p": "正在建立 P2P",
- "viewer.msg.preparingSfu": "正在连接备用线路",
- "viewer.msg.allocating": "正在分配线路",
- "viewer.msg.receiving": "正在接收画面",
- "viewer.msg.playing": "正在播放",
- "viewer.msg.needsPlay": "点击播放",
- "viewer.msg.hostPaused": "分享者已暂停",
- "viewer.msg.recovering": "正在恢复连接",
- "viewer.msg.routeFailed": "没有可用的媒体线路",
- "viewer.msg.playbackFailed": "浏览器无法播放当前画面",
- "viewer.msg.hostOffline": "分享者连接已中断",
- "viewer.msg.serverError": "连接服务暂时不可用",
- "viewer.msg.notFound": "房间不存在或已过期",
- "viewer.msg.denied": "当前无法通过房间号加入",
- "viewer.msg.invalidInvite": "邀请链接无效或已失效",
- "viewer.msg.expired": "房间已过期",
- "viewer.msg.closed": "房间已关闭",
- "viewer.msg.full": "当前无法加入房间",
- "viewer.msg.stale": "页面版本已更新,请刷新后重试",
- "viewer.msg.sessionReplaced": "此页面的会话已被另一个标签页接管",
- "viewer.msg.signalTerminated": "连接已终止,请刷新后重试",
- "viewer.notice.signalRecovering": "服务器连接正在恢复,画面仍在播放",
- "viewer.notice.mediaRecovering": "媒体连接正在恢复",
- "viewer.notice.hostOffline": "分享者连接已中断,画面可能冻结",
- "viewer.hint.denied": "请使用分享者提供的邀请链接,或尝试房间密码。",
- "viewer.hint.notFound": "请确认房间号,或向分享者获取新的邀请链接。",
- "viewer.hint.invite": "请向分享者获取新的邀请链接。",
- "viewer.hint.generic": "请检查入口后重试。",
- "viewer.error.p2p": "P2P 媒体连接异常",
- "viewer.error.relay": "下游媒体连接异常",
-
- "mode.language": "界面语言",
- "mode.zh": "中文",
- "mode.en": "English",
- "mode.vis": "纯视觉",
- "theme.dark": "切换到暗色模式",
- "theme.light": "切换到浅色模式",
- "theme.dark.short": "暗色",
- "theme.light.short": "浅色",
-
- "story.room": "找到房间",
- "story.link": "建立连接",
- "story.show": "接收画面",
-
- "gate.connectFailed": "无法连接站点访问服务,请重试",
- "gate.expired": "站点访问已失效,请重新验证",
- "gate.serviceUnavailable": "站点验证服务暂时不可用 ({status})",
-
- "host.onlineCount": "{n} / {max} 人在线",
- "host.notStarted": "尚未开始",
- "host.startCancelled": "启动已取消",
- "host.switchingSource": "正在切换来源",
- "host.capture.fpsUnknown": "帧率未知",
- "host.capture.codecPending": "编码待定",
- "host.capture.hasAudio": "含音频",
- "host.capture.noAudio": "无音频",
- "host.stageAria": "分享或加入房间",
- "host.captureAria": "实际捕获参数",
- "host.quality.title": "{label} · {mbps} Mbps",
- "host.audio.title": "{label} · {kbps} kbps 上限",
- "host.roomExpired": "房间已过期",
- "host.roomClosed": "房间已关闭",
- "host.pause.noTracksResume": "当前分享没有可恢复的媒体轨道",
- "host.pause.signalRecovering": "服务器连接正在恢复,分享仍保持暂停",
- "host.pause.noTracksPause": "当前分享没有可暂停的媒体轨道",
- "host.pause.stillPaused": "分享仍保持暂停",
- "host.shareEnded": "当前分享已经结束",
- "host.fail.start": "启动分享失败",
- "host.err.createConnection": "创建连接失败",
- "host.err.codecUnsupported": "当前浏览器无法使用支持的视频编码",
- "host.err.applySender": "应用发送参数失败",
- "host.err.applyAudioSender": "应用音频发送参数失败",
- "host.fail.source": "切换分享来源失败",
- "host.fail.quality": "应用画质设置失败",
- "host.fail.connection": "观看连接处理失败",
- "host.fail.room": "房间操作失败",
- "host.err.invalidToken": "分享凭证已失效,请重新创建房间",
- "host.err.accessDenied": "当前操作没有权限",
- "host.err.roomExpired": "房间已过期,请重新创建",
- "host.err.alreadyConnected": "此房间已在另一个页面中分享",
- "host.err.peerGone": "对应的观看连接已经离开",
- "host.err.forbidden": "当前操作不可用",
- "host.err.serverError": "服务暂时不可用,请稍后重试",
- "host.err.createRoomStatus": "当前无法创建房间 ({status})",
- "host.err.replaceRoomStatus": "当前无法更换房间 ({status})",
- "host.err.updateRoomStatus": "当前无法更新房间设置 ({status})",
- "host.capture.cancelled": "屏幕选择已取消或没有共享权限",
- "host.capture.noSource": "没有可用的屏幕分享来源",
- "host.capture.readFailed": "浏览器暂时无法读取所选分享来源",
- "host.capture.unavailable": "当前页面无法启动屏幕分享",
- "host.notice.reconnecting": "部分观看者正在重新连接",
- "host.notice.sfuRecovering": "SFU 分享来源未切换成功,正在恢复观看连接",
- "host.password.inputPlaceholder": "输入密码",
-
- "stats.warn.codec": "视频编码为 {codec},预期 H264 或 VP8",
- "stats.warn.audioCodec": "音频编码为 {codec},预期 Opus",
-
- "viewer.msg.joinUnavailable": "暂时无法加入房间",
- "viewer.stageAria": "共享画面",
-
- "host.warn.audioUnread": "浏览器未读回音频码率上限",
- "host.warn.bandwidth": "当前连接带宽受限,画质已自动降低",
- "host.warn.encoding": "编码性能受限,画质已自动降低",
- "host.warn.other": "浏览器持续报告其他画质限制",
- "host.warn.unclassified": "浏览器持续报告未分类的画质限制",
- "host.warn.audioRewritten": "浏览器将音频码率上限改写为 {kbps} kbps",
- "host.warn.senderPartial": "浏览器未完整接受{params}",
- "host.warn.param.maxBitrate": "码率上限",
- "host.warn.param.maxFramerate": "帧率上限",
- "host.warn.param.scaleResolutionDownBy": "分辨率缩放",
- "host.warn.param.degradationPreference": "质量优先级",
- "host.warn.param.scalabilityMode": "伸缩模式",
- "host.warn.sfuRecover": "SFU {stage}失败,已启动自动恢复",
- "host.warn.sfuStage.connect": "连接",
- "host.warn.sfuStage.source": "分享源",
- "host.warn.sfuStage.videoPublish": "视频发布",
- "host.warn.sfuStage.senderConfig": "视频参数配置",
- "host.warn.sfuStage.audioPublish": "音频发布",
- "host.warn.sfuStage.transport": "传输",
- "host.fail.sfuSwitch": "切换 SFU 分享来源失败",
- "host.fail.sfuAudioParams": "应用 SFU 音频发送参数失败",
- "host.fail.sfuParams": "应用 SFU 发送参数失败",
-} as const;
-
-const en: Record<keyof typeof zh, string> = {
- "brand.home": "Screener home",
-
- "common.roomCode": "Room code",
- "common.copy": "Copy",
- "common.copied": "Copied",
- "common.copyFailed": "Copy failed",
- "common.cancel": "Cancel",
- "common.retry": "Retry",
- "common.refresh": "Refresh page",
- "common.edit": "Edit",
- "common.close": "Close",
- "common.viewers": "Viewers",
- "common.you": "you",
- "common.host": "Host",
- "common.name.viewerDefault": "Visitor",
- "common.name.hostDefault": "Host",
-
- "gate.title": "Site access",
- "gate.hint": "Enter the site passphrase",
- "gate.password": "Site passphrase",
- "gate.submit": "Enter site",
- "gate.checking": "Checking site access",
- "gate.wrong": "Incorrect passphrase, try again",
- "gate.unavailable": "Site access cannot be verified right now",
- "gate.malformed": "Invalid room code format",
- "gate.malformedHint": "Enter a four-digit room code between 1000 and 9999",
- "gate.unavailableRoute": "Unavailable",
-
- "join.title": "Join a room",
- "join.hint": "Enter the four-digit room code from your friend",
- "join.field": "Room code",
- "join.submit": "Join",
- "join.invalid": "Enter a four-digit room code between 1000 and 9999",
- "join.joining": "Joining the room",
- "join.notFound": "Room not found or expired",
- "join.notFoundHint": "Check the room code, or ask the host for a new invite link.",
- "join.denied": "This room cannot be joined by code right now",
- "join.deniedHint": "Use the host's invite link, or try the room password.",
- "join.password": "Room password",
- "join.passwordError": "Could not join; try again",
- "join.passwordRule": "Enter 1-{max} visible characters",
- "join.passwordAction": "Enter room password",
- "join.full": "Room is full",
-
- "host.title": "{name}'s screen",
- "host.idle.heading": "Something worth watching?",
- "host.idle.hint": "Share your screen and friends can drop in with the room code or invite link.",
- "host.start": "Start sharing",
- "host.join": "Join a room",
- "host.starting": "Connecting",
- "host.cancelStart": "Cancel",
- "host.live": "Live",
- "host.paused": "Paused",
- "host.ended": "Sharing stopped",
- "host.roomReady": "Room ready",
- "host.pause": "Pause sharing",
- "host.resume": "Resume sharing",
- "host.switchSource": "Switch source",
- "host.switching": "Choosing",
- "host.stop": "Stop sharing",
- "host.noAudio": "This source has no shareable audio",
- "host.localPreviewPaused": "Local preview paused; sharing continues",
- "host.pauseNotice": "Audio and video sharing paused",
- "host.resumeNotice": "Audio and video sharing resumed",
- "host.stopNotice": "Sharing stopped",
- "host.roomReplaced": "Room code replaced",
- "host.roomInvalid": "Room expired; press again to create a new one",
- "host.roomReplace": "Replace room code",
- "host.roomReplaceConfirm": "Confirm replacing the room code",
- "host.captureError": "Screen capture unavailable; check browser permission and retry",
- "host.terminated.stale": "Page updated; refresh to continue",
- "host.terminated.session": "This page's session was taken over by another tab",
- "host.terminated.signal": "Server connection terminated; refresh to continue",
- "host.notice.qualityApplied": "Share settings applied",
- "host.notice.qualitySet": "Quality switched to {label}",
- "host.notice.audioSet": "Audio quality switched to {label}",
- "host.notice.partialApply": "Settings updated, but some viewer connections could not apply them",
- "host.notice.sourceSwitch.ok": "Share source switched",
- "host.notice.sourceSwitch.partial": "Source switched, but {warning}",
-
- "host.name": "Display name",
- "host.nameSave": "Save display name",
- "host.nameCancel": "Cancel editing",
- "host.nameEdit": "Edit display name",
- "host.nameError": "Invalid name, or longer than 24 characters",
- "host.nameOffline": "Display name can only change while sharing and connected",
-
- "host.invite": "Invite link",
- "host.invite.copy": "Copy invite link",
- "host.invite.copyFailed": "Could not copy the invite link; try again",
- "host.invite.rotate": "Rotate invite link",
- "host.invite.revoke": "Revoke invite link",
- "host.invite.rotateShort": "Rotate link",
- "host.invite.revokeShort": "Revoke link",
- "host.invite.updated": "Invite link rotated",
- "host.invite.revoked": "Invite link revoked",
- "host.invite.emptyOpen": "No invite link; the room code still works",
- "host.invite.emptyPassword": "No invite link; room code plus password still works",
- "host.invite.emptyPrivate": "No invite link; rotate one before inviting",
-
- "host.policy": "Admission",
- "host.policy.open": "Open",
- "host.policy.private": "Private",
- "host.policy.openHint": "Anyone with the room code can join",
- "host.policy.privateHint": "Invite link only, or set a room password",
- "host.policy.setOpen": "Room is now open",
- "host.policy.setPrivateInvite": "Room is now private, invite link only",
- "host.policy.setPrivatePassword": "Room is now private, invite link or password",
- "host.password.set": "Room password set",
- "host.password.unset": "No room password",
- "host.password.placeholder": "Set one to allow code entry",
- "host.password.setAction": "Set room password",
- "host.password.changeAction": "Change room password",
- "host.password.remove": "Remove room password",
- "host.password.show": "Show room password",
- "host.password.hide": "Hide room password",
- "host.password.saved": "Room password set",
- "host.password.updated": "Room password updated",
- "host.password.removed": "Password removed; invite link only",
- "host.password.rule": "1-{max} visible characters",
- "host.accessFailed": "Cannot update room settings right now; try again later",
-
- "host.viewers.empty": "No viewers yet",
- "host.viewers.waiting": "Waiting for friends to join",
-
- "host.quality": "Video preset",
- "host.quality.720p30": "720p · 30 fps",
- "host.quality.1080p30": "1080p · 30 fps",
- "host.quality.1080p60": "1080p · 60 fps",
- "host.advanced": "Advanced settings",
- "host.advanced.resolution": "Resolution ceiling",
- "host.advanced.framerate": "Frame rate ceiling",
- "host.advanced.bitrate": "Video bitrate ceiling",
- "host.advanced.preference": "Picture preference",
- "host.advanced.preference.resolution": "Clarity",
- "host.advanced.preference.balanced": "Balanced",
- "host.advanced.preference.framerate": "Fluency",
- "host.advanced.preference.resolutionHint": "Keep detail",
- "host.advanced.preference.balancedHint": "Weigh automatically",
- "host.advanced.preference.framerateHint": "Prefer frame rate",
- "host.advanced.audio": "Audio quality",
- "host.advanced.audio.saver": "Standard",
- "host.advanced.audio.music": "Music",
- "host.advanced.audio.veryHigh": "Studio",
- "host.advanced.route": "Route policy",
- "host.advanced.route.topo": "Auto topology tuning",
- "host.advanced.route.topoHint": "Gradually pick healthier paths while live",
- "host.advanced.route.peerOnly": "Pure P2P",
- "host.advanced.route.peerOnlyHint": "No media server; stop when direct paths fail",
- "host.advanced.codec": "Video codec",
- "host.advanced.codec.auto": "Auto",
- "host.advanced.codec.autoHint": "Pick automatically",
- "host.advanced.codec.vp8Hint": "Compatibility first",
- "host.advanced.codec.h264Hint": "Hardware first",
-
- "host.details": "Show connection details",
- "host.details.hide": "Hide connection details",
- "host.topology": "Connection topology",
- "host.topology.show": "Show connection topology",
- "host.topology.hide": "Hide connection topology",
- "host.topology.pending": "Connecting",
- "host.sfu": "Media server",
-
- "state.signal.connected": "Server connected",
- "state.signal.connecting": "Connecting",
- "state.signal.reconnecting": "Recovering",
- "state.signal.offline": "Server offline",
- "state.peer.connected": "Connected",
- "state.peer.connecting": "Connecting",
- "state.peer.routing": "Routing",
- "state.peer.waiting": "Waiting for share",
- "state.peer.reconnecting": "Recovering",
- "state.peer.failed": "Connection failed",
- "state.peer.disconnected": "Connection lost",
- "state.peer.closed": "Closed",
- "state.peer.new": "Preparing",
- "state.route.p2p": "P2P direct",
- "state.route.sfu": "Via server",
-
- "stats.title": "Connection data",
- "stats.relay": "Relay data",
- "stats.downstream": "Downstream receive data",
- "stats.more": "Detailed metrics",
- "stats.less": "Hide detailed metrics",
- "stats.resolution": "Resolution",
- "stats.fps": "Frame rate",
- "stats.bitrate": "Bitrate",
- "stats.loss": "Packet loss",
- "stats.rtt": "RTT",
- "stats.codec": "Video codec",
- "stats.jitter": "Jitter",
- "stats.dropped": "Dropped frames",
- "stats.encoder": "Encoder",
- "stats.audio": "Audio bitrate",
- "stats.unknown": "Unknown",
- "stats.outgoing": "Available uplink",
- "stats.qualityState": "Quality state",
- "stats.quality.normal": "Normal",
- "stats.quality.bandwidth": "Bandwidth-limited",
- "stats.quality.cpu": "Encoder-limited",
- "stats.quality.other": "Other limit",
- "stats.quality.unclassified": "Unclassified limit",
- "stats.capture": "Capture settings",
- "stats.inputFps": "Encoder input rate",
- "stats.encodeMs": "Encode time/frame",
- "stats.decodeMs": "Decode time/frame",
- "stats.freezeCount": "Freezes",
- "stats.freezeDuration": "Freeze duration",
- "stats.audioLoss": "Audio packet loss",
- "stats.audioJitter": "Audio jitter",
- "stats.playoutDelta": "A/V playout delta",
- "stats.videoBuffer": "Video buffer",
- "stats.audioBuffer": "Audio buffer",
- "stats.audioConcealedRate": "Audio concealment rate",
- "stats.audioConcealed": "Audio concealments",
-
- "viewer.title": "{name}'s screen",
- "viewer.titleFallback": "A friend's screen",
- "viewer.reconnect": "Reconnect media",
- "viewer.msg.joining": "Joining the room",
- "viewer.msg.waitingHost": "Waiting for the host to share",
- "viewer.msg.preparingP2p": "Establishing P2P",
- "viewer.msg.preparingSfu": "Connecting backup route",
- "viewer.msg.allocating": "Allocating a route",
- "viewer.msg.receiving": "Receiving video",
- "viewer.msg.playing": "Playing",
- "viewer.msg.needsPlay": "Tap to play",
- "viewer.msg.hostPaused": "Host paused",
- "viewer.msg.recovering": "Recovering connection",
- "viewer.msg.routeFailed": "No media route available",
- "viewer.msg.playbackFailed": "The browser cannot play this stream",
- "viewer.msg.hostOffline": "Host connection lost",
- "viewer.msg.serverError": "Connection service unavailable",
- "viewer.msg.notFound": "Room not found or expired",
- "viewer.msg.denied": "This room cannot be joined by code right now",
- "viewer.msg.invalidInvite": "Invite link invalid or expired",
- "viewer.msg.expired": "Room expired",
- "viewer.msg.closed": "Room closed",
- "viewer.msg.full": "Cannot join the room right now",
- "viewer.msg.stale": "Page updated; refresh to continue",
- "viewer.msg.sessionReplaced": "This page's session was taken over by another tab",
- "viewer.msg.signalTerminated": "Connection terminated; refresh to continue",
- "viewer.notice.signalRecovering": "Server reconnecting; video keeps playing",
- "viewer.notice.mediaRecovering": "Media connection recovering",
- "viewer.notice.hostOffline": "Host connection lost; picture may freeze",
- "viewer.hint.denied": "Use the host's invite link, or try the room password.",
- "viewer.hint.notFound": "Check the room code, or ask the host for a new invite link.",
- "viewer.hint.invite": "Ask the host for a new invite link.",
- "viewer.hint.generic": "Check your entry point and try again.",
- "viewer.error.p2p": "P2P media connection error",
- "viewer.error.relay": "Downstream media connection error",
-
- "mode.language": "Interface language",
- "mode.zh": "中文",
- "mode.en": "English",
- "mode.vis": "Visual only",
- "theme.dark": "Switch to dark mode",
- "theme.light": "Switch to light mode",
- "theme.dark.short": "Dark",
- "theme.light.short": "Light",
-
- "story.room": "Room found",
- "story.link": "Linking up",
- "story.show": "Receiving picture",
-
- "gate.connectFailed": "Cannot reach the site access service; try again",
- "gate.expired": "Site access expired; verify again",
- "gate.serviceUnavailable": "Site access service unavailable ({status})",
-
- "host.onlineCount": "{n} / {max} online",
- "host.notStarted": "Not started",
- "host.startCancelled": "Start cancelled",
- "host.switchingSource": "Switching source",
- "host.capture.fpsUnknown": "Unknown frame rate",
- "host.capture.codecPending": "Codec pending",
- "host.capture.hasAudio": "With audio",
- "host.capture.noAudio": "No audio",
- "host.stageAria": "Share or join a room",
- "host.captureAria": "Actual capture parameters",
- "host.quality.title": "{label} · {mbps} Mbps",
- "host.audio.title": "{label} · {kbps} kbps ceiling",
- "host.roomExpired": "Room expired",
- "host.roomClosed": "Room closed",
- "host.pause.noTracksResume": "No resumable media tracks in the current share",
- "host.pause.signalRecovering": "Server reconnecting; sharing stays paused",
- "host.pause.noTracksPause": "No pausable media tracks in the current share",
- "host.pause.stillPaused": "Sharing stays paused",
- "host.shareEnded": "The current share has ended",
- "host.fail.start": "Failed to start sharing",
- "host.err.createConnection": "Failed to create the connection",
- "host.err.codecUnsupported": "This browser cannot use a supported video codec",
- "host.err.applySender": "Failed to apply sender parameters",
- "host.err.applyAudioSender": "Failed to apply audio sender parameters",
- "host.fail.source": "Failed to switch share source",
- "host.fail.quality": "Failed to apply quality settings",
- "host.fail.connection": "Viewer connection handling failed",
- "host.fail.room": "Room operation failed",
- "host.err.invalidToken": "Share credentials expired; create the room again",
- "host.err.accessDenied": "Not permitted",
- "host.err.roomExpired": "Room expired; create it again",
- "host.err.alreadyConnected": "This room is already shared in another page",
- "host.err.peerGone": "The viewer connection has left",
- "host.err.forbidden": "Action unavailable",
- "host.err.serverError": "Service temporarily unavailable; try again later",
- "host.err.createRoomStatus": "Cannot create a room right now ({status})",
- "host.err.replaceRoomStatus": "Cannot change rooms right now ({status})",
- "host.err.updateRoomStatus": "Cannot update room settings right now ({status})",
- "host.capture.cancelled": "Screen selection cancelled or not permitted",
- "host.capture.noSource": "No shareable screen source available",
- "host.capture.readFailed": "The browser cannot read the selected source right now",
- "host.capture.unavailable": "This page cannot start screen sharing",
- "host.notice.reconnecting": "Some viewers are reconnecting",
- "host.notice.sfuRecovering": "SFU source switch failed; restoring viewer connections",
- "host.password.inputPlaceholder": "Enter password",
-
- "stats.warn.codec": "Video codec is {codec}; expected H264 or VP8",
- "stats.warn.audioCodec": "Audio codec is {codec}; expected Opus",
-
- "viewer.msg.joinUnavailable": "Cannot join the room right now",
- "viewer.stageAria": "Shared picture",
-
- "host.warn.audioUnread": "The browser did not report the audio bitrate ceiling",
- "host.warn.bandwidth": "This connection is bandwidth-limited; quality was reduced automatically",
- "host.warn.encoding": "Encoding performance is limited; quality was reduced automatically",
- "host.warn.other": "The browser keeps reporting other quality limits",
- "host.warn.unclassified": "The browser keeps reporting an unclassified quality limit",
- "host.warn.audioRewritten": "The browser rewrote the audio bitrate ceiling to {kbps} kbps",
- "host.warn.senderPartial": "The browser did not fully accept {params}",
- "host.warn.param.maxBitrate": "bitrate ceiling",
- "host.warn.param.maxFramerate": "frame rate ceiling",
- "host.warn.param.scaleResolutionDownBy": "resolution scaling",
- "host.warn.param.degradationPreference": "quality preference",
- "host.warn.param.scalabilityMode": "scalability mode",
- "host.warn.sfuRecover": "SFU {stage} failed; automatic recovery started",
- "host.warn.sfuStage.connect": "connect",
- "host.warn.sfuStage.source": "source",
- "host.warn.sfuStage.videoPublish": "video publish",
- "host.warn.sfuStage.senderConfig": "sender config",
- "host.warn.sfuStage.audioPublish": "audio publish",
- "host.warn.sfuStage.transport": "transport",
- "host.fail.sfuSwitch": "Failed to switch the SFU share source",
- "host.fail.sfuAudioParams": "Failed to apply SFU audio sender parameters",
- "host.fail.sfuParams": "Failed to apply SFU sender parameters",
-};
-
-export type CopyKey = keyof typeof zh;
-
-const CATALOGS: Record<Lang, Record<CopyKey, string>> = { zh, en };
-
const LANG_STORAGE_KEY = "screener:ui-lang";
const MODE_STORAGE_KEY = "screener:ui-mode";
@@ -787,7 +90,7 @@ if (typeof window !== "undefined") {
export const setCopy = commit;
export function t(lang: Lang, key: CopyKey, vars?: Record<string, string>): string {
- let value = CATALOGS[lang][key];
+ let value = catalogs[lang][key];
if (vars) {
for (const [name, replacement] of Object.entries(vars)) {
value = value.replace(`{${name}}`, replacement);
@@ -796,6 +99,14 @@ export function t(lang: Lang, key: CopyKey, vars?: Record<string, string>): stri
return value;
}
+export function getTitleFrames(
+ lang: Lang,
+ visual: boolean,
+ key: TitleFrameKey,
+): readonly string[] {
+ return visual ? visualTitleFrames[key] : titleFrameCatalogs[lang][key];
+}
+
// Non-hook accessor for transient notices composed outside React render
// (pages keep resolved strings in state; a language switch leaves an already
// shown notice in its original language until replaced).
@@ -815,6 +126,7 @@ export interface Copy {
lang: Lang;
vis: boolean;
t: (key: CopyKey, vars?: Record<string, string>) => string;
+ titleFrames: (key: TitleFrameKey) => readonly string[];
setLang: (lang: Lang) => void;
setVis: (vis: boolean) => void;
}
@@ -830,10 +142,12 @@ export function useCopy(): Copy {
snapshot,
);
const [lang, vis] = current.split(":") as [Lang, string];
+ const visual = vis === "true";
return {
lang,
- vis: vis === "true",
+ vis: visual,
t: (key, vars) => t(lang, key, vars),
+ titleFrames: (key) => getTitleFrames(lang, visual, key),
setLang: (next) => commit({ lang: next, vis: false }),
setVis: (next) => commit({ vis: next }),
};
diff --git a/src/client/ui/document-title.ts b/src/client/ui/document-title.ts
new file mode 100644
index 00000000..7046825f
--- /dev/null
+++ b/src/client/ui/document-title.ts
@@ -0,0 +1,52 @@
+import { useEffect } from "react";
+
+const BRAND_TITLE = "Screener";
+const TITLE_VARIATION_INTERVAL_MS = 15_000;
+
+export function composeDocumentTitle(
+ ...parts: Array<string | null | undefined>
+): string {
+ const detail = parts.filter((part): part is string => Boolean(part));
+ return detail.length > 0
+ ? `${BRAND_TITLE} | ${detail.join(" · ")}`
+ : BRAND_TITLE;
+}
+
+export function useDocumentTitle(
+ parts: Array<string | null | undefined>,
+ variations: readonly string[] = [],
+): void {
+ const title = composeDocumentTitle(...parts);
+ const variationKey = variations.join("\u001f");
+ useEffect(() => {
+ document.title = title;
+ const currentPart = parts.at(-1);
+ const frames = currentPart ? [currentPart, ...variations] : [];
+ if (
+ frames.length < 2 ||
+ window.matchMedia("(prefers-reduced-motion: reduce)").matches
+ ) {
+ return () => {
+ document.title = BRAND_TITLE;
+ };
+ }
+
+ const prefix = parts.slice(0, -1);
+ let frameIndex = 0;
+ const timer = window.setInterval(() => {
+ if (document.visibilityState !== "visible") {
+ return;
+ }
+ frameIndex =
+ frameIndex === 0
+ ? 1 + Math.floor(Math.random() * (frames.length - 1))
+ : 0;
+ document.title = composeDocumentTitle(...prefix, frames[frameIndex]);
+ }, TITLE_VARIATION_INTERVAL_MS);
+
+ return () => {
+ window.clearInterval(timer);
+ document.title = BRAND_TITLE;
+ };
+ }, [title, variationKey]);
+}
diff --git a/src/client/ui/icons.tsx b/src/client/ui/icons.tsx
index 0decbe3b..2f16326c 100644
--- a/src/client/ui/icons.tsx
+++ b/src/client/ui/icons.tsx
@@ -43,6 +43,7 @@ const PATHS: Record<string, { body: ReactNode; solid?: boolean }> = {
gauge: { body: (<><path pathLength={1} d="M4 14.5a8 8 0 1 1 16 0"/><path pathLength={1} d="m12 14 3.5-4"/><path pathLength={1} d="M3.5 17.5h17"/></>) },
drop: { body: (<><path pathLength={1} d="M12 3s6 6.4 6 11a6 6 0 0 1-12 0c0-4.6 6-11 6-11Z"/></>) },
expand: { body: (<><path pathLength={1} d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></>) },
+ contract: { body: (<><path pathLength={1} d="M8 3v5H3m13-5v5h5M8 21v-5H3m13 5v-5h5"/></>) },
wave: { body: (<><path pathLength={1} d="M2 12c1.7 0 1.7-2.5 3.4-2.5S7 12 8.7 12s1.6-2.5 3.3-2.5S13.6 12 15.3 12s1.7-2.5 3.4-2.5S20.3 12 22 12"/></>) },
speaker: { body: (<><path pathLength={1} d="M4 9v6h4l5 4V5L8 9H4Z"/><path pathLength={1} d="M16 9a4.2 4.2 0 0 1 0 6M18.5 6.5a8 8 0 0 1 0 11"/></>) },
sliders: { body: (<><path pathLength={1} d="M3 6h9m4 0h5M3 12h3m4 0h11M3 18h12m4 0h2"/><circle pathLength={1} cx="14" cy="6" r="2"/><circle pathLength={1} cx="8" cy="12" r="2"/><circle pathLength={1} cx="17" cy="18" r="2"/></>) },
diff --git a/src/client/ui/theme.ts b/src/client/ui/theme.ts
index 28970759..6775cfc8 100644
--- a/src/client/ui/theme.ts
+++ b/src/client/ui/theme.ts
@@ -1,15 +1,16 @@
// Light/dark theme with system default, persistence, and no-flash startup.
-// index.html applies the stored/system theme before first paint; this module
-// owns runtime toggles.
+// index.html applies the stored/system theme before first paint. Until the user
+// chooses explicitly, this module continues following system changes.
import { useSyncExternalStore } from "react";
export type Theme = "light" | "dark";
const THEME_STORAGE_KEY = "screener:ui-theme";
+const DARK_THEME_QUERY = "(prefers-color-scheme: dark)";
function detectTheme(): Theme {
return typeof window !== "undefined" &&
- window.matchMedia?.("(prefers-color-scheme: dark)").matches
+ window.matchMedia?.(DARK_THEME_QUERY).matches
? "dark"
: "light";
}
@@ -22,23 +23,50 @@ function readInitial(): Theme {
return detectTheme();
}
-const state: { theme: Theme } = { theme: "light" };
+function storedTheme(): Theme | null {
+ try {
+ const value = window.localStorage.getItem(THEME_STORAGE_KEY);
+ return value === "light" || value === "dark" ? value : null;
+ } catch {
+ return null;
+ }
+}
+
+const state: { theme: Theme; explicit: boolean; initialized: boolean } = {
+ theme: "light",
+ explicit: false,
+ initialized: false,
+};
const listeners = new Set<() => void>();
-export function applyTheme(theme: Theme): void {
+function commitTheme(theme: Theme): void {
+ if (state.theme === theme) return;
state.theme = theme;
document.documentElement.dataset.theme = theme;
+ listeners.forEach((listener) => listener());
+}
+
+export function applyTheme(theme: Theme): void {
+ state.explicit = true;
+ commitTheme(theme);
try {
window.localStorage.setItem(THEME_STORAGE_KEY, theme);
} catch {
// Restricted storage only disables persistence.
}
- listeners.forEach((listener) => listener());
}
export function initTheme(): void {
- state.theme = readInitial();
+ const stored = storedTheme();
+ state.explicit = stored !== null;
+ state.theme = stored ?? readInitial();
document.documentElement.dataset.theme = state.theme;
+ if (!state.initialized && typeof window.matchMedia === "function") {
+ state.initialized = true;
+ window.matchMedia(DARK_THEME_QUERY).addEventListener("change", (event) => {
+ if (!state.explicit) commitTheme(event.matches ? "dark" : "light");
+ });
+ }
}
export function useTheme(): { theme: Theme; toggle: () => void } {
diff --git a/src/shared/protocol.ts b/src/shared/protocol.ts
index ea3c513f..d6471a6a 100644
--- a/src/shared/protocol.ts
+++ b/src/shared/protocol.ts
@@ -23,7 +23,7 @@ export const VIEWER_QUALITY_EVIDENCE_INTERVAL_MS = 2_000;
export const VIEWER_QUALITY_EVIDENCE_EXPIRY_MS = 5_000;
export const PERSISTENT_NATIVE_EDGE_DEGRADED_WINDOWS = 3;
export const MAX_DISPLAY_NAME_CODE_POINTS = 24;
-export const DEFAULT_VIEWER_DISPLAY_NAME = "访客";
+export const DEFAULT_VIEWER_DISPLAY_NAME = "观众";
export const DEFAULT_HOST_DISPLAY_NAME_PREFIX = "分享者";
export const MIN_VIEWER_PASSWORD_LENGTH = 1;
export const MAX_VIEWER_PASSWORD_LENGTH = 64;
diff --git a/tests/client-state.test.ts b/tests/client-state.test.ts
index e8ea68f2..0663a4f3 100644
--- a/tests/client-state.test.ts
+++ b/tests/client-state.test.ts
@@ -14,9 +14,12 @@ import {
replaceOwnedRoom,
} from "../src/client/lib/api.ts";
import {
+ defaultHostDisplayName,
+ defaultViewerDisplayName,
readDisplayName,
saveDisplayName,
} from "../src/client/lib/display-name.ts";
+import { setCopy } from "../src/client/ui/copy.ts";
import {
clearHostRoom,
getStableClientId,
@@ -55,9 +58,23 @@ import {
afterEach(() => {
vi.useRealTimers();
vi.unstubAllGlobals();
+ setCopy({ lang: "zh", vis: false });
});
describe("browser-local display name", () => {
+ it("localizes text defaults and uses visual emoji identities", () => {
+ setCopy({ lang: "zh", vis: false });
+ expect(defaultViewerDisplayName("viewer-abcdef", false)).toBe("观众");
+ expect(defaultHostDisplayName("host-abcdef", false)).toBe("分享者-abcdef");
+
+ setCopy({ lang: "en", vis: false });
+ expect(defaultViewerDisplayName("viewer-abcdef", false)).toBe("Viewer");
+ expect(defaultHostDisplayName("host-abcdef", false)).toBe("Host-abcdef");
+
+ expect(defaultViewerDisplayName("viewer-abcdef", true)).toBe("👀-abcdef");
+ expect(defaultHostDisplayName("host-abcdef", true)).toBe("📺-abcdef");
+ });
+
it("stores only the canonical preference and falls back when cleared", () => {
const values = new Map<string, string>();
vi.stubGlobal("window", {
@@ -73,8 +90,8 @@ describe("browser-local display name", () => {
expect(saveDisplayName("\u202ehidden")).toBeNull();
expect(saveDisplayName("\n")).toBeNull();
expect(readDisplayName()).toBe("Café 玩家");
- expect(saveDisplayName(" ")).toBe("访客");
- expect(readDisplayName()).toBe("访客");
+ expect(saveDisplayName(" ")).toBe("观众");
+ expect(readDisplayName()).toBe("观众");
});
it("extends only colliding room-scoped peer ID suffixes", () => {
@@ -241,8 +258,8 @@ describe("browser-local display name", () => {
"viewer_sfu_child",
);
expect(topology.pending.map((entry) => entry.peerId)).toEqual([
- "viewer_pending",
"viewer_orphan",
+ "viewer_pending",
]);
});
});
diff --git a/tests/copy.test.ts b/tests/copy.test.ts
index a7184354..87c10780 100644
--- a/tests/copy.test.ts
+++ b/tests/copy.test.ts
@@ -1,6 +1,12 @@
import { afterEach, describe, expect, it, vi } from "vitest";
-import { say, setCopy, t, type CopyKey } from "../src/client/ui/copy.ts";
+import {
+ getTitleFrames,
+ say,
+ setCopy,
+ t,
+ type CopyKey,
+} from "../src/client/ui/copy.ts";
describe("copy catalog", () => {
afterEach(() => {
@@ -12,6 +18,8 @@ describe("copy catalog", () => {
const zh = t("zh", "join.title");
expect(zh).toBe("加入房间");
expect(t("en", "join.title")).toBe("Join a room");
+ expect(t("zh", "host.advanced.route.peerOnly")).toBe("隐私模式");
+ expect(t("en", "host.advanced.route.peerOnly")).toBe("Privacy mode");
});
it("interpolates variables", () => {
@@ -37,6 +45,24 @@ describe("copy catalog", () => {
expect(say("common.copied")).toBe("Copied");
});
+ it("keeps title variations in the selected content catalog", () => {
+ const zhHost = getTitleFrames("zh", false, "hostActive");
+ const enViewer = getTitleFrames("en", false, "viewerActive");
+ const visualViewer = getTitleFrames("zh", true, "viewerActive");
+
+ expect(zhHost[0]).toBe("分享中");
+ expect(zhHost).toContain("小电视上工");
+ expect(enViewer[0]).toBe("Watching");
+ expect(enViewer).toContain("Popcorn ready");
+ expect(visualViewer[0]).toBe("📺");
+ expect(visualViewer).toContain("📺 🍿");
+ expect(getTitleFrames("zh", false, "hostIdle")).toContain("天线在打盹");
+ expect(getTitleFrames("en", false, "viewerWaiting")).toContain(
+ "Couch saved you a spot",
+ );
+ expect(getTitleFrames("zh", true, "hostReady")).toContain("🛋️ 🍵");
+ });
+
it("keeps the document language aligned with the selected catalog", () => {
const documentElement = { lang: "zh-CN" };
vi.stubGlobal("document", { documentElement });
diff --git a/tests/living-components.test.ts b/tests/living-components.test.ts
index 4ef5e56d..f78d16c9 100644
--- a/tests/living-components.test.ts
+++ b/tests/living-components.test.ts
@@ -2,15 +2,21 @@ import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { afterEach, describe, expect, it } from "vitest";
-import { Couch } from "../src/client/components/living/Couch.tsx";
+import {
+ Couch,
+ pawnColor,
+} from "../src/client/components/living/Couch.tsx";
import {
BrandLoader,
BrandMark,
} from "../src/client/components/living/BrandMark.tsx";
import { Comic } from "../src/client/components/living/Comic.tsx";
import { ComicTooltip } from "../src/client/components/living/ComicTooltip.tsx";
+import { HintComic } from "../src/client/components/living/hints/index.tsx";
import { StageOverlay } from "../src/client/components/living/Stage.tsx";
+import { ViewerOverview } from "../src/client/components/living/ViewerOverview.tsx";
import { NameTag } from "../src/client/components/living/primitives.tsx";
+import { EMPTY_METRICS } from "../src/client/types.ts";
import { setCopy } from "../src/client/ui/copy.ts";
describe("living-room presentation", () => {
@@ -115,6 +121,18 @@ describe("living-room presentation", () => {
expect(html).not.toContain('viewBox="0 0 320 96"');
});
+ it("animates the private-room hint around its door and lock", () => {
+ const html = renderToStaticMarkup(
+ createElement(HintComic, { kind: "hint-policy-private", size: 240 }),
+ );
+
+ expect(html).toContain("vls-priv-door");
+ expect(html).toContain("vls-priv-lock");
+ expect(html).toContain("vls-priv-card");
+ expect(html).toContain("vlsPrivDoor");
+ expect(html).toContain("vlsPrivLock");
+ });
+
it("keeps every crowded and relay Viewer name visible in visual mode", () => {
setCopy({ lang: "en", vis: true });
const html = renderToStaticMarkup(
@@ -126,15 +144,77 @@ describe("living-room presentation", () => {
? "Relay Viewer With A Full Name"
: `Viewer ${index}`,
connected: true,
- child: index === 11,
})),
}),
);
expect(html).toContain("lr-pawns is-crowded");
expect(html).toContain(
- '<span class="lr-pawn-name is-mini">Relay Viewer With A Full Name</span>',
+ '<span class="lr-pawn-name">Relay Viewer With A Full Name</span>',
);
expect(html).not.toContain("max-width:72px");
});
+
+ it("derives every participant color only from the peer identity", () => {
+ const peerId = "viewer-stable-identity";
+ const color = pawnColor(peerId);
+ const html = renderToStaticMarkup(
+ createElement(Couch, {
+ entries: [
+ {
+ key: peerId,
+ name: "Self",
+ connected: true,
+ you: true,
+ },
+ ],
+ }),
+ );
+
+ expect(pawnColor(peerId)).toBe(color);
+ expect(html).toContain(color);
+ expect(html).not.toContain("var(--you)");
+ });
+
+ it("shows all Viewer primary metrics in one compact selectable overview", () => {
+ const html = renderToStaticMarkup(
+ createElement(ViewerOverview, {
+ entries: [
+ {
+ key: "viewer-a",
+ name: "Alice",
+ connected: true,
+ statusLabel: "Connected",
+ route: "p2p",
+ metrics: {
+ ...EMPTY_METRICS,
+ resolution: "1920x1080",
+ framesPerSecond: 59.8,
+ bitrateKbps: 5120,
+ packetLossPercent: 0.4,
+ rttMs: 18,
+ },
+ },
+ {
+ key: "viewer-b",
+ name: "Bob",
+ connected: false,
+ statusLabel: "Routing",
+ route: null,
+ metrics: null,
+ },
+ ],
+ selectedKey: "viewer-a",
+ onSelect: () => undefined,
+ }),
+ );
+
+ expect(html).toContain("lr-viewer-overview-row is-selected");
+ expect(html).toContain("Alice");
+ expect(html).toContain("1920x1080");
+ expect(html).toContain("59.8");
+ expect(html).toContain("5120");
+ expect(html).toContain("18 ms");
+ expect(html).toContain("Bob");
+ });
});
diff --git a/tests/protocol.test.ts b/tests/protocol.test.ts
index e016691a..a71d9a17 100644
--- a/tests/protocol.test.ts
+++ b/tests/protocol.test.ts
@@ -391,7 +391,7 @@ describe("client signaling protocol", () => {
displayName: " Cafe\u0301 ",
}).success,
).toBe(false);
- expect(DEFAULT_VIEWER_DISPLAY_NAME).toBe("访客");
+ expect(DEFAULT_VIEWER_DISPLAY_NAME).toBe("观众");
});
it("accepts only canonical bounded Viewer grants and access actions", () => {
diff --git a/tests/route-tree.test.ts b/tests/route-tree.test.ts
index bd82dd32..b254ff8f 100644
--- a/tests/route-tree.test.ts
+++ b/tests/route-tree.test.ts
@@ -10,6 +10,28 @@ import { setCopy } from "../src/client/ui/copy.ts";
afterEach(() => setCopy({ lang: "zh", vis: false }));
describe("RouteTree", () => {
+ it("sorts every Viewer by stable peer identity", () => {
+ const { viewers } = labelParticipantSnapshot([
+ {
+ role: "viewer",
+ peerId: "viewer-z",
+ displayName: "Z",
+ upstream: { kind: "none" },
+ },
+ {
+ role: "viewer",
+ peerId: "viewer-a",
+ displayName: "A",
+ upstream: { kind: "none" },
+ },
+ ]);
+
+ expect(viewers.map((viewer) => viewer.peerId)).toEqual([
+ "viewer-a",
+ "viewer-z",
+ ]);
+ });
+
it("uses real-size narrow coordinates without compressing deep trees", () => {
const narrow = topologyLayoutForViewport(true);
const desktop = topologyLayoutForViewport(false);
@@ -258,6 +280,45 @@ describe("RouteTree", () => {
expect(html).toContain("← Host");
});
+ it("exposes only authorized topology nodes as detail controls", () => {
+ const { host, viewers } = labelParticipantSnapshot([
+ {
+ role: "host",
+ peerId: "host",
+ displayName: "Host",
+ upstream: { kind: "none" },
+ },
+ {
+ role: "viewer",
+ peerId: "viewer-a",
+ displayName: "Alice",
+ upstream: { kind: "peer", peerId: "host" },
+ mediaReady: true,
+ },
+ {
+ role: "viewer",
+ peerId: "viewer-b",
+ displayName: "Bob",
+ upstream: { kind: "peer", peerId: "host" },
+ mediaReady: true,
+ },
+ ]);
+ const html = renderToStaticMarkup(
+ createElement(RouteTree, {
+ hostPeerId: host?.peerId ?? null,
+ hostLabel: host?.label ?? "Host",
+ viewers,
+ selectablePeerIds: ["viewer-b"],
+ onSelectPeer: () => undefined,
+ }),
+ );
+
+ expect(html.match(/class="lr-route-hit"/g)).toHaveLength(1);
+ expect(html).toContain('role="button"');
+ expect(html).toContain('aria-label="Bob · 显示连接详情"');
+ expect(html).not.toContain('aria-label="Alice · 显示连接详情"');
+ });
+
it("gives every reachable depth its own horizontal column", () => {
const participants = [
{
diff --git a/tests/server-signal.test.ts b/tests/server-signal.test.ts
index 1a9cbbde..eada95d7 100644
--- a/tests/server-signal.test.ts
+++ b/tests/server-signal.test.ts
@@ -896,7 +896,7 @@ describe("WebSocket signaling", () => {
expect(viewerPresenceEntries(full).map((viewer) => viewer.displayName)).toEqual([
"阿明",
"阿青",
- "访客",
+ "观众",
]);
expect(
viewerPresenceEntries(full).filter(
diff --git a/tests/theme.test.ts b/tests/theme.test.ts
new file mode 100644
index 00000000..04349fc1
--- /dev/null
+++ b/tests/theme.test.ts
@@ -0,0 +1,52 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { composeDocumentTitle } from "../src/client/ui/document-title.ts";
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+ vi.resetModules();
+});
+
+describe("theme preference", () => {
+ it("keeps room state compact and the product name first", () => {
+ expect(composeDocumentTitle("7063", "Sharing")).toBe(
+ "Screener | 7063 · Sharing",
+ );
+ expect(composeDocumentTitle()).toBe("Screener");
+ });
+
+ it("follows the system until the user chooses explicitly", async () => {
+ const values = new Map<string, string>();
+ let dark = false;
+ let onChange = (_event: { matches: boolean }): void => undefined;
+ const dataset: Record<string, string> = {};
+ vi.stubGlobal("document", { documentElement: { dataset } });
+ vi.stubGlobal("window", {
+ localStorage: {
+ getItem: (key: string) => values.get(key) ?? null,
+ setItem: (key: string, value: string) => values.set(key, value),
+ },
+ matchMedia: () => ({
+ matches: dark,
+ addEventListener: (
+ _event: string,
+ listener: (event: { matches: boolean }) => void,
+ ) => {
+ onChange = listener;
+ },
+ }),
+ });
+
+ const theme = await import("../src/client/ui/theme.ts");
+ theme.initTheme();
+ expect(dataset.theme).toBe("light");
+
+ dark = true;
+ onChange({ matches: dark });
+ expect(dataset.theme).toBe("dark");
+
+ theme.applyTheme("light");
+ expect(values.get("screener:ui-theme")).toBe("light");
+ onChange({ matches: true });
+ expect(dataset.theme).toBe("light");
+ });
+});