mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 12:02:50 +08:00
Fix screen-share letterboxing across skins
This commit is contained in:
1 parent
acdc7a2330
commit
833357e278
22 files changed
+67
-65
No files matched your search
@@ -117,7 +117,6 @@
|
||||
import Icon from "../Icon.vue";
|
||||
import { onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import type { useWebClientScreenShare } from "../../composables/useWebClientScreenShare.js";
|
||||
import { calculateScreenSharePlayerSize } from "../../composables/useWebClientScreenShare.js";
|
||||
const props = defineProps<{
|
||||
model: Pick<ReturnType<typeof useWebClientScreenShare>, "fullscreen" | "viewers" | "viewerCount" | "ownerName" | "errorText" | "setPlayerElement" | "setVideoElement" | "viewerStyle" | "setVolume" | "toggleFullscreen">;
|
||||
screenShareRemoteStream: MediaStream | null; screenShareRemoteVolume: number; screenShareError: string;
|
||||
@@ -138,7 +137,6 @@ function setInlineStyle(element: HTMLElement, property: string, value: string |
|
||||
function updateStageSize(): void {
|
||||
const stage = stageElement.value;
|
||||
const player = playerElement.value ?? stage?.parentElement ?? null;
|
||||
const video = stage?.querySelector("video");
|
||||
if (!stage || !player) return;
|
||||
if (screenShareFullscreen.value) {
|
||||
setInlineStyle(player, "width", "100vw");
|
||||
@@ -150,24 +148,9 @@ function updateStageSize(): void {
|
||||
}
|
||||
setInlineStyle(player, "width", null);
|
||||
setInlineStyle(player, "height", null);
|
||||
if (!video?.videoWidth || !video.videoHeight) {
|
||||
setInlineStyle(stage, "width", null);
|
||||
setInlineStyle(stage, "height", null);
|
||||
setInlineStyle(stage, "aspect-ratio", "16 / 9");
|
||||
return;
|
||||
}
|
||||
const parentWidth = stage.parentElement?.parentElement?.clientWidth || window.innerWidth;
|
||||
const size = calculateScreenSharePlayerSize(
|
||||
video.videoWidth,
|
||||
video.videoHeight,
|
||||
Math.min(parentWidth, 1100),
|
||||
Math.max(220, Math.min(window.innerHeight - 220, 720)),
|
||||
);
|
||||
if (!size) return;
|
||||
setInlineStyle(player, "width", `${size.width + 2}px`);
|
||||
setInlineStyle(stage, "width", `${size.width}px`);
|
||||
setInlineStyle(stage, "height", `${size.height}px`);
|
||||
setInlineStyle(stage, "aspect-ratio", `${video.videoWidth} / ${video.videoHeight}`);
|
||||
setInlineStyle(stage, "width", null);
|
||||
setInlineStyle(stage, "height", null);
|
||||
setInlineStyle(stage, "aspect-ratio", "16 / 9");
|
||||
}
|
||||
|
||||
function setPlayerElementNode(element: unknown): void {
|
||||
|
||||
@@ -10,20 +10,6 @@ interface ScreenShareResolutionOption {
|
||||
label: string;
|
||||
}
|
||||
|
||||
export function calculateScreenSharePlayerSize(
|
||||
sourceWidth: number,
|
||||
sourceHeight: number,
|
||||
maxWidth: number,
|
||||
maxHeight: number,
|
||||
): { width: number; height: number } | null {
|
||||
if (![sourceWidth, sourceHeight, maxWidth, maxHeight].every((value) => Number.isFinite(value) && value > 0)) return null;
|
||||
const scale = Math.min(maxWidth / sourceWidth, maxHeight / sourceHeight);
|
||||
return {
|
||||
width: Math.max(1, Math.floor(sourceWidth * scale)),
|
||||
height: Math.max(1, Math.floor(sourceHeight * scale)),
|
||||
};
|
||||
}
|
||||
|
||||
interface UseWebClientScreenShareOptions {
|
||||
streams: ScreenShareStream[];
|
||||
viewing: Ref<boolean>;
|
||||
|
||||
@@ -21,12 +21,16 @@ test("built-in appearance manifests and catalog versions match the bundled share
|
||||
for (const manifest of [lightManifest, darkManifest]) {
|
||||
assert.equal(BUILTIN_SKIN_CATALOG.find((skin) => skin.id === manifest.id)?.version, manifest.version);
|
||||
}
|
||||
assert.equal(lightManifest.version, "1.0.1");
|
||||
assert.equal(darkManifest.version, "1.0.1");
|
||||
assert.equal(lightManifest.version, "1.0.2");
|
||||
assert.equal(darkManifest.version, "1.0.2");
|
||||
assert.match(lightCss, /\.screen-share-live-indicator\s*\{[^}]*background:/s);
|
||||
assert.match(lightCss, /\.screen-share-card-button\.viewing\s*\{[^}]*background:/s);
|
||||
assert.match(darkCss, /\.screen-share-live-indicator\s*\{[^}]*background:/s);
|
||||
assert.match(darkCss, /\.screen-share-card-button\.viewing\s*\{[^}]*background:/s);
|
||||
assert.match(lightCss, /screen-player\.stage"\] \{ background: #000; \}/);
|
||||
assert.match(lightCss, /screen-player\.video"\] \{ object-fit: contain; background: #000; \}/);
|
||||
assert.match(darkCss, /screen-player\.stage"\] \{ background: #000; \}/);
|
||||
assert.match(darkCss, /screen-player\.video"\] \{ object-fit: contain; background: #000; \}/);
|
||||
});
|
||||
|
||||
test("skin catalog always includes protected built-ins and exposes only enabled custom skins", async () => {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
|
||||
{
|
||||
id: "builtin.light",
|
||||
name: "Day mode",
|
||||
version: "1.0.1",
|
||||
version: "1.0.2",
|
||||
author: "WebSpeak",
|
||||
license: "AGPL-3.0-only",
|
||||
description: "The default light appearance.",
|
||||
@@ -21,7 +21,7 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
|
||||
{
|
||||
id: "builtin.dark",
|
||||
name: "Night mode",
|
||||
version: "1.0.1",
|
||||
version: "1.0.2",
|
||||
author: "WebSpeak",
|
||||
license: "AGPL-3.0-only",
|
||||
description: "The default dark appearance.",
|
||||
@@ -33,7 +33,7 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
|
||||
{
|
||||
id: BUILTIN_ILLUSIA_SKIN_ID,
|
||||
name: "ILLUSIA风",
|
||||
version: "2.0.1",
|
||||
version: "2.0.2",
|
||||
author: "WebSpeak Project",
|
||||
license: "All rights reserved",
|
||||
description: "A bright original-character art skin with a safe declarative live-channel badge.",
|
||||
@@ -46,7 +46,7 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
|
||||
{
|
||||
id: BUILTIN_KAAK_SKIN_ID,
|
||||
name: "KAAK",
|
||||
version: "3.1.73",
|
||||
version: "3.1.74",
|
||||
author: "WebSpeak Project",
|
||||
license: "AGPL-3.0-only",
|
||||
description: "A KOOK-inspired voice-room workspace with a searchable server header, TeamSpeak banner and welcome message, nested channel members, attached channel chat, and a compact WebSpeak audio dock.",
|
||||
|
||||
@@ -77,12 +77,23 @@ test("custom skins can override theme appearance without !important or private c
|
||||
);
|
||||
});
|
||||
|
||||
test("community skins use a scoped light fallback instead of inheriting the night skin", async () => {
|
||||
test("community skins use a scoped light fallback instead of inheriting the night skin", async () => {
|
||||
const lightCss = await readFile(new URL("../skins/builtin/light/skin.css", import.meta.url), "utf8");
|
||||
const scoped = scopeBuiltinThemeForCustomSkin(lightCss, "light", "community.illusia-voice");
|
||||
assert.match(scoped, /:where\(\.ws-skin-root\[data-ws-skin="community\.illusia-voice"\]\) \{\s*color-scheme: light;/);
|
||||
assert.match(scoped, /:where\(\.ws-skin-root\[data-ws-skin="community\.illusia-voice"\]\) \.settings-content/);
|
||||
});
|
||||
});
|
||||
|
||||
test("built-in light and dark skins keep letterbox areas black", async () => {
|
||||
const [light, dark] = await Promise.all([
|
||||
readFile(new URL("../skins/builtin/light/skin.css", import.meta.url), "utf8"),
|
||||
readFile(new URL("../skins/builtin/dark/skin.css", import.meta.url), "utf8"),
|
||||
]);
|
||||
for (const [css, id] of [[light, "builtin.light"], [dark, "builtin.dark"]] as const) {
|
||||
assert.match(css, new RegExp(`data-ws-skin="${id}"[^{}]*\\[data-ws-part="voice\\.screen-player\\.stage"\\] \\{ background: #000; \\}`));
|
||||
assert.match(css, new RegExp(`data-ws-skin="${id}"[^{}]*\\[data-ws-part="voice\\.screen-player\\.video"\\] \\{ object-fit: contain; background: #000; \\}`));
|
||||
}
|
||||
});
|
||||
|
||||
async function componentSources(directory: string): Promise<string> {
|
||||
const componentRoot = new URL(directory, import.meta.url);
|
||||
@@ -141,7 +152,7 @@ test("the ILLUSIA v3 example and bundled package import without replacing WebSpe
|
||||
const skin = await importSkinPack(new File([exampleBytes], "illusia-voice.wskin", { type: "application/octet-stream" }));
|
||||
assert.equal(skin.id, "community.illusia-voice");
|
||||
assert.equal(skin.name, "ILLUSIA风");
|
||||
assert.equal(skin.version, "2.0.1");
|
||||
assert.equal(skin.version, "2.0.2");
|
||||
assert.equal(skin.schemaVersion, 3);
|
||||
assert.equal(skin.packageType, "open-skin");
|
||||
assert.equal(skin.layoutData, undefined);
|
||||
@@ -171,6 +182,8 @@ test("the ILLUSIA v3 example and bundled package import without replacing WebSpe
|
||||
assert.match(skin.css, /data-ws-plugin-part="illusia-now-playing\.channel-name"/);
|
||||
assert.match(skin.css, /data-ws-part="voice\.member\.live-indicator"\]\s*\{[^}]*border-color:[^}]*background:/s);
|
||||
assert.match(skin.css, /data-ws-part="voice\.member\.share-actions"\] \.screen-share-card-button\.viewing\s*\{[^}]*background:/s);
|
||||
assert.match(skin.css, /data-ws-part="voice\.screen-player\.stage"\]\s*\{[^}]*background: #000/);
|
||||
assert.match(skin.css, /data-ws-part="voice\.screen-player\.video"\]\s*\{[^}]*object-fit: contain;[^}]*background: #000/);
|
||||
assert.match(skin.css, /data-ws-part="home\.server-history\.item"/);
|
||||
assert.match(skin.css, /data-ws-part="home\.server-history\.favorite-toggle"\]\[data-ws-state="saved"\]/);
|
||||
assert.match(skin.css, /data-ws-part="voice\.favorite-servers\.favorite-toggle"\]\[data-ws-state="saved"\]/);
|
||||
@@ -225,8 +238,8 @@ test("the activity artwork layer floats above room content without intercepting
|
||||
assert.match(css, /:deep\(\.app-shell \.chat-panel \.section-heading\),[\s\S]*?:deep\(\.app-shell \.chat-panel \.message-composer\)\s*\{\s*position: relative;\s*z-index: 3;/);
|
||||
assert.match(css, /\.screen-share-player\)?\s*\{[^}]*background: var\(--surface-1\)/);
|
||||
assert.match(css, /\.screen-share-player-exit\)?\s*\{[^}]*z-index: 3;/);
|
||||
assert.match(css, /\.screen-share-player-stage\)?\s*\{[^}]*var\(--accent\)[^}]*var\(--surface-2\)/);
|
||||
assert.match(css, /\.screen-share-player-video\)?\s*\{[^}]*background: var\(--surface-2\)/);
|
||||
assert.match(css, /\.screen-share-player-stage\)?\s*\{[^}]*background: #000/);
|
||||
assert.match(css, /\.screen-share-player-video\)?\s*\{[^}]*object-fit: contain;[^}]*background: #000/);
|
||||
assert.match(css, /@media \(min-width: 741px\)\s*\{\s*\/\* Keep header menus above the independently stacked screen-share stage\. \*\/\s*\.app-shell \.workspace-header\s*\{\s*position: relative;\s*z-index: 40;/);
|
||||
});
|
||||
|
||||
@@ -466,7 +479,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
|
||||
const file = new File([archive], "kaak-voice.wskin", { type: "application/octet-stream" });
|
||||
const skin = await importSkinPack(file);
|
||||
assert.equal(skin.id, "community.kaak-voice");
|
||||
assert.equal(skin.version, "3.1.73");
|
||||
assert.equal(skin.version, "3.1.74");
|
||||
assert.equal(BUILTIN_SKIN_CATALOG.find((entry) => entry.id === skin.id)?.version, skin.version);
|
||||
assert.equal(skin.schemaVersion, 3);
|
||||
const home = skin.pluginData?.components.find((component) => component.page === "home");
|
||||
@@ -695,6 +708,8 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
|
||||
assert.match(skin.css, /kaak-workspace\.member-cards[\s\S]*?\.voice-card[\s\S]*?aspect-ratio: 1\.82;/);
|
||||
assert.match(skin.css, /kaak-workspace\.member-cards[\s\S]*?\.screen-share-live-indicator[\s\S]*?background: #20251e;/);
|
||||
assert.match(skin.css, /kaak-workspace\.member-cards[\s\S]*?\.screen-share-card-button\.viewing[\s\S]*?background: #8be31e;/);
|
||||
assert.match(skin.css, /kaak-workspace"\] \[data-ws-part="voice\.screen-player\.stage"\]\s*\{[^}]*background: #000/);
|
||||
assert.match(skin.css, /kaak-workspace"\] \[data-ws-part="voice\.screen-player\.video"\]\s*\{[^}]*object-fit: contain;[^}]*background: #000/);
|
||||
assert.match(skin.css, /@keyframes ws-community-kaak-voice-kaak-member-speaking-wave/);
|
||||
assert.ok(skin.css.includes("animation: ws-community-kaak-voice-kaak-performance-refresh-spin .72s linear infinite;"));
|
||||
assert.ok(skin.css.includes("performance-refresh:disabled .ui-icon { animation: none; }"));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"schemaVersion": 1,
|
||||
"id": "builtin.dark",
|
||||
"name": "WebSpeak Dark",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"author": "WebSpeak",
|
||||
"license": "AGPL-3.0-only",
|
||||
"description": "The built-in dark appearance for public WebSpeak pages.",
|
||||
|
||||
@@ -277,6 +277,8 @@
|
||||
.ws-skin-root[data-ws-skin="builtin.dark"] *::-webkit-scrollbar-thumb:hover { background: #69c7bc; }
|
||||
|
||||
/* Keep live screen sharing obvious in the built-in dark voice roster. */
|
||||
.ws-skin-root[data-ws-skin="builtin.dark"] [data-ws-part="voice.screen-player.stage"] { background: #000; }
|
||||
.ws-skin-root[data-ws-skin="builtin.dark"] [data-ws-part="voice.screen-player.video"] { object-fit: contain; background: #000; }
|
||||
.ws-skin-root[data-ws-skin="builtin.dark"] .screen-share-live-indicator {
|
||||
color: #bdfff1;
|
||||
border-color: rgba(105, 210, 199, .48);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"schemaVersion": 1,
|
||||
"id": "builtin.light",
|
||||
"name": "WebSpeak Light",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"author": "WebSpeak",
|
||||
"license": "AGPL-3.0-only",
|
||||
"description": "The built-in light appearance for public WebSpeak pages.",
|
||||
|
||||
@@ -150,6 +150,8 @@
|
||||
}
|
||||
|
||||
/* Keep live screen sharing obvious in the built-in light voice roster. */
|
||||
.ws-skin-root[data-ws-skin="builtin.light"] [data-ws-part="voice.screen-player.stage"] { background: #000; }
|
||||
.ws-skin-root[data-ws-skin="builtin.light"] [data-ws-part="voice.screen-player.video"] { object-fit: contain; background: #000; }
|
||||
.ws-skin-root[data-ws-skin="builtin.light"] .screen-share-live-indicator {
|
||||
color: #075f56;
|
||||
border-color: #a9d8d0;
|
||||
|
||||
@@ -7158,7 +7158,7 @@
|
||||
box-sizing: border-box;
|
||||
place-items: center;
|
||||
overflow: hidden;
|
||||
background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--accent) 12%, var(--surface-1)), var(--surface-2) 74%);
|
||||
background: #000;
|
||||
}
|
||||
|
||||
:deep(.screen-share-player-video) {
|
||||
@@ -7168,7 +7168,7 @@
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
background: var(--surface-2);
|
||||
background: #000;
|
||||
}
|
||||
|
||||
:deep(.screen-share-player-placeholder) {
|
||||
|
||||
Reference in new issue
Block a user