## Problem and outcome / 问题与结果 App authorization could stay busy after a stalled save, a pending microphone request could survive a capture-source handoff, and compact room controls could lose focus, position or readable names. This maintenance phase corrects those owners and makes connection help easier to find. ## Verification / 验证 Validation: the exact candidate tree passed all 1,943 Web tests and documentation checks. Its unchanged product source has passed TypeScript and a production Web build. Controlled UI checks cover delayed microphone permission, stalled approval responses, keyboard viewport changes, rapid floating-panel hide/show and narrow nickname layouts. Published 2.x wire, native control and storage contracts are unchanged. ## Impact / 影响 Compatible 2.x maintenance release. Existing App, site and persisted room contracts are retained. Matching packages, download mirrors and both managed sites are verified through the normal release workflow. ## Release notes **Piik, now in your pocket.** Piik App supports Android screen sharing, with touch controls for a friend's computer. **手机,也能开播。** Piik App 支持 Android 屏幕分享,也能用手机控制朋友的电脑。 ### English This maintenance update improves App authorization, capture-source switching and controls on smaller screens. - Fix commentary controls remaining busy after switching from Browser capture to the App. - Let App site approval recover from a stalled save, keeping access already granted. - Preserve numeric-input focus when the mobile keyboard resizes the page, and provide increase/decrease buttons. Keep interaction windows at their remembered position after rapid hide/show actions. - Give nicknames readable space on smaller screens, while retaining edit controls and accessible labels. Keep launcher diagnostics inside the shared Help menu. - Make room-connection help easier to find, and clarify Safari screen-sharing and sound support. - Complete package mirroring after a later CI publication step fails, and verify managed-service deployments against the intended source revision. This maintenance update preserves the established 2.x room, invitation, media, App-control and storage contracts. Refresh a site's open pages after it is updated. App-local users need the updated App bundle to receive its included Web fixes. Existing compatible 2.x App/site workflows remain supported. ### 中文 本次维护更新改善 App 授权、切换分享源和小屏操作。 - 修复浏览器切换为 App 采集后,分享麦克风控制一直处于忙碌状态的问题。 - App 站点授权不再因保存卡住而一直转圈;可以重试,已批准的授权也会保留。 - 手机键盘改变页面尺寸时保留数字输入焦点,并提供增减按钮;互动窗口快速隐藏再打开后保留记忆位置。 - 小屏上为昵称保留可读空间,同时保留编辑入口与无障碍名称;启动页诊断统一收进帮助菜单。 - 更容易找到房间连接问题的排查入口,并说明 Safari 屏幕分享与声音的支持情况。 - 发布流程后续步骤失败时,仍可补全已经发布的程序包镜像;部署核验明确比对预期源码版本。 本维护更新保留既有 2.x 房间、邀请、媒体、App 控制与存储契约。 站点更新后请刷新已打开的网页;App 本地使用者需更新程序包,才能使用其中的新网页修复。 已有兼容的 2.x App/站点使用方式继续支持。
145 lines
7.4 KiB
TypeScript
145 lines
7.4 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { runInNewContext } from "node:vm";
|
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
import { createElement } from "react";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
import ts from "typescript";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { VideoRateControls } from "../src/client/components/living/QualityPresets";
|
|
import { QUALITY_PROFILES, VIDEO_CAPTURE_LIMITS } from "../src/client/media/quality";
|
|
|
|
// Exercise the shared draft owner without adding a DOM runtime to unit tests.
|
|
// Real pointer/focus ordering is also checked in the existing Browser preview.
|
|
const source = ts.createSourceFile("NumberControl.tsx", readFileSync(
|
|
new URL("../src/client/components/living/NumberControl.tsx", import.meta.url), "utf8",
|
|
), ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
const owner = source.statements.find(node => ts.isFunctionDeclaration(node) && node.name?.text === "NumberControl");
|
|
if (!owner) throw new Error("Missing numeric quality draft owner");
|
|
const executable = ts.transpileModule(`${owner.getText(source)}\nNumberControl;`, {
|
|
fileName: "NumberControl.tsx",
|
|
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS, jsx: ts.JsxEmit.ReactJSX },
|
|
}).outputText;
|
|
|
|
function editor() {
|
|
const input = { value: "128", validity: { valid: true },
|
|
get valueAsNumber() { return this.value === "" ? NaN : Number(this.value); } };
|
|
const inside = {};
|
|
const container = { contains: (node: unknown) => node === inside };
|
|
const onChange = vi.fn();
|
|
const setInvalid = vi.fn();
|
|
const render = runInNewContext(executable, {
|
|
exports: {}, require: () => jsxRuntime, useRef: () => ({ current: input }), Number,
|
|
useState: () => [false, setInvalid], useId: () => "validation", useCopy: () => ({ t: vi.fn() }), Glyph: () => null,
|
|
useEffect: (effect: () => void) => effect(),
|
|
});
|
|
let choose!: (next: number) => void;
|
|
let key!: (event: unknown) => void;
|
|
const result = render({ value: 128, min: 6, max: 320, step: 1, unit: "kbps", name: "audioBitrate",
|
|
label: "Audio bitrate", disabled: false, onChange, className: "lr-door-group",
|
|
children: (number: { props: { children: { props: { onKeyDown: typeof key } }[] } }, select: typeof choose) => {
|
|
choose = select;
|
|
key = number.props.children[0]!.props.onKeyDown;
|
|
return number;
|
|
},
|
|
});
|
|
const blur = (relatedTarget: unknown = null) => result.props.onBlur({ currentTarget: container, relatedTarget });
|
|
const press = (value: string) => key({ key: value, nativeEvent: { isComposing: false }, currentTarget: { blur: () => blur() },
|
|
preventDefault() {}, stopPropagation() {} });
|
|
return { input, inside, onChange, choose, blur, press, setInvalid };
|
|
}
|
|
|
|
describe("Numeric quality editing group", () => {
|
|
it.each([
|
|
{ fps: 30, mbps: 5, maxFps: 240, maxMbps: 240, sliderFps: 60, sliderMbps: 12 },
|
|
{ fps: 15, mbps: 5, maxFps: 30, maxMbps: 10, sliderFps: 30, sliderMbps: 10 },
|
|
{ fps: 25, mbps: 5, maxFps: 29, maxMbps: 5.2, sliderFps: 25, sliderMbps: 5 },
|
|
])("keeps common sliders separate from accepted input limits ($maxFps fps, $maxMbps Mbps)", test => {
|
|
const onChange = vi.fn();
|
|
const html = renderToStaticMarkup(createElement(VideoRateControls, {
|
|
value: { ...QUALITY_PROFILES["1080p30"], maxFramerate: test.fps, maxBitrate: test.mbps * 1_000_000 },
|
|
limits: { ...VIDEO_CAPTURE_LIMITS, maxVideoFramerate: test.maxFps, maxVideoBitrate: test.maxMbps * 1_000_000 },
|
|
disabled: false, onChange,
|
|
}));
|
|
const inputs = html.match(/<input\b[^>]*>/g)!;
|
|
const numbers = inputs.filter(input => input.includes('type="number"'));
|
|
const sliders = inputs.filter(input => input.includes('type="range"'));
|
|
for (const [index, value, max, sliderMin, sliderMax, step] of [
|
|
[0, test.fps, test.maxFps, 15, test.sliderFps, 5], [1, test.mbps, test.maxMbps, 2, test.sliderMbps, 0.5],
|
|
] as const) {
|
|
expect(numbers[index]).toContain(`max="${max}"`);
|
|
expect(numbers[index]).toContain(`value="${value}"`);
|
|
expect(sliders[index]).toContain(`min="${sliderMin}"`);
|
|
expect(sliders[index]).toContain(`max="${sliderMax}"`);
|
|
expect(sliders[index]).toContain(`step="${step}"`);
|
|
expect(sliders[index]).toContain(`value="${value}"`);
|
|
}
|
|
expect(onChange).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it.each([
|
|
{ fps: 144, mbps: 80, maxFps: 240, maxMbps: 240, returnFps: 60, returnMbps: 12 },
|
|
{ fps: 5, mbps: 0.5, maxFps: 240, maxMbps: 240, returnFps: 15, returnMbps: 2 },
|
|
{ fps: 29, mbps: 5.1, maxFps: 240, maxMbps: 240, returnFps: 30, returnMbps: 5 },
|
|
{ fps: 29, mbps: 5.2, maxFps: 29, maxMbps: 5.2, returnFps: 25, returnMbps: 5 },
|
|
{ fps: 8, mbps: 0.5, maxFps: 10, maxMbps: 1, returnFps: null, returnMbps: null },
|
|
])("preserves custom values without an inaccurate slider ($fps fps, $mbps Mbps)", test => {
|
|
const onChange = vi.fn();
|
|
const html = renderToStaticMarkup(createElement(VideoRateControls, {
|
|
value: { ...QUALITY_PROFILES["1080p30"], maxFramerate: test.fps, maxBitrate: test.mbps * 1_000_000 },
|
|
limits: { ...VIDEO_CAPTURE_LIMITS, maxVideoFramerate: test.maxFps, maxVideoBitrate: test.maxMbps * 1_000_000 },
|
|
disabled: false, onChange,
|
|
}));
|
|
const fields = html.split('<div class="lr-quality-rate">').slice(1);
|
|
expect(fields).toHaveLength(2);
|
|
for (const [index, value, nearest, unit] of [[0, test.fps, test.returnFps, "fps"], [1, test.mbps, test.returnMbps, "Mbps"]] as const) {
|
|
expect(fields[index]).toContain(`value="${value}"`);
|
|
expect(fields[index]).not.toContain('type="range"');
|
|
expect(fields[index]).toContain('class="lr-quality-custom"');
|
|
if (nearest === null) expect(fields[index]).not.toContain('class="lr-btn is-dense"');
|
|
else expect(fields[index]).toMatch(new RegExp(`<button[^>]*aria-label="[^"]*${nearest} ${unit}`));
|
|
}
|
|
expect(onChange).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("preserves a draft through group navigation or cancelled selection, then commits on leaving", () => {
|
|
const current = editor();
|
|
current.input.value = "256";
|
|
current.blur(current.inside);
|
|
expect(current.onChange).not.toHaveBeenCalled();
|
|
expect(current.input.value).toBe("256");
|
|
current.blur();
|
|
expect(current.onChange.mock.calls).toEqual([[256]]);
|
|
});
|
|
|
|
it.each([64, 128])("a choice of %s replaces the draft before a subsequent blur", next => {
|
|
const current = editor();
|
|
current.input.value = "256";
|
|
current.blur(current.inside);
|
|
current.choose(next);
|
|
current.blur();
|
|
expect(current.input.value).toBe("128");
|
|
expect(current.onChange.mock.calls).toEqual(next === 128 ? [] : [[next]]);
|
|
});
|
|
|
|
it.each(["Enter", "Escape"])("handles %s through the same group boundary", key => {
|
|
const current = editor();
|
|
current.input.value = "256";
|
|
current.press(key);
|
|
expect(current.onChange.mock.calls).toEqual(key === "Enter" ? [[256]] : []);
|
|
if (key === "Escape") expect(current.input.value).toBe("128");
|
|
});
|
|
|
|
it.each(["", "321"])("marks an invalid draft (%s) without losing or applying it", value => {
|
|
const current = editor();
|
|
current.input.value = value;
|
|
current.input.validity.valid = value === "";
|
|
current.blur();
|
|
expect(current.input.value).toBe(value);
|
|
expect(current.setInvalid).toHaveBeenLastCalledWith(true);
|
|
expect(current.onChange).not.toHaveBeenCalled();
|
|
current.choose(128);
|
|
expect(current.input.value).toBe("128");
|
|
expect(current.setInvalid).toHaveBeenLastCalledWith(false);
|
|
});
|
|
});
|