This release adds microphone processing controls and local chat controls, expands platform packages, and synchronizes the website and guides. It also fixes native H.264 input/format handling, signaling recovery, fresh STUN discovery, and UDP ownership during overlapping connections. This is **v1.8.0**. Browser/Server v23, Native control v9 and capture v7 remain unchanged, with the existing 1440p ceiling. Additional resolutions, capability negotiation and Magicsock are separate follow-up work. ## Validation - Full local Web check: 79 files / 1,317 tests, TypeScript and production build. - Full Go checks, platform builds and Windows native capture regressions/probe. - Native H.264 Host lifecycle, Browser-to-App fanout and App-exit recovery, and Native H.264 through embedded SFU: all passed with owned process/port/profile cleanup. - Website build, documentation and repository hygiene passed. Existing UI acceptance covers narrow screens, both languages/themes, architecture downloads and all 23 film checks; final packaging and Go race checks run on the merged revision in CI. - Physical macOS/Linux capture, representative public networks and unmatched field reports retain their documented evidence limits. No claim that every blur/disconnection report is resolved. ## Release notes ### 中文 这是一次功能与兼容性更新:麦克风和聊天增加了实用的小选项,App 与 Server 支持更多设备,同时修复了原生分享和连接恢复中的若干问题。现有 1.x 协议保持不变。 #### 新增与改进 - 浏览器麦克风新增「降噪与回声消除」开关,默认开启回声消除、降噪和自动增益;分享音乐或使用虚拟音频输入时,可按需关闭。 - 可调整弹幕字号和透明度,并将当前保留的聊天记录导出为 TXT。当前会话最多保留 1,000 条文字消息,刷新页面后清空;需要保存时请先导出。 - 新增 Intel Mac、Linux ARM64 App,以及 Linux ARM64 Server 和容器镜像。官网下载区可直接选择对应架构,并显示最新版本和发布时间。 - 更新官网演示、README 截图和中英文教程,明确浏览器分享也可选择窗口或屏幕;开始分享前显示房间号占位,保持底栏控件位置稳定。 - 官网新增直达问题排查的入口,补充浏览器 WebRTC 限制、校园网和 Windows 显卡相关的排查步骤。 - App 模式选择页显示免费开源说明、作者与贡献者署名,以及官方网站和源码链接。 #### 修复 - 修正部分 H.264 原生分享的格式兼容性校验,以及 Windows 编码器输入长度和输出缓冲区对齐问题。 - 清理已失效的重连任务和 Native 接收信令,避免旧连接继续影响当前会话。 - 修复 App 重连时可能复用过期公网地址的问题;重新探测使用当前地址,并处理探测丢包和过期响应,保留其他正常连接。 - 修复 App 新旧媒体连接重叠时共用端口造成的冲突,避免准备或撤销新连接打断仍在使用的画面;关闭连接时及时取消未完成的端口映射请求。 - 无站点密码时,连接恢复不再误引导用户输入站点密码。 - 房间失效或会话终止时,开播前后的原因提示统一显示在电视状态图标中,避免额外提示条。 - 修正 Linux 原生采集的时间戳与关键帧时间基准。感谢 Pedro Antonio 在 [#449](https://github.com/TNTcraftHIM/Piik/pull/449) 的贡献。 #### 使用说明 下载对应平台的完整压缩包,退出旧 App 后解压使用。Windows 继续提供 x64;macOS 提供 Apple 芯片与 Intel 版本,原生采集需要 macOS 13 或更新版本。Linux 提供 x64 与 ARM64,原生采集还需安装[系统组件](https://github.com/TNTcraftHIM/Piik/blob/main/native/capture/linux/README.md)。macOS 和 Linux 的实机覆盖仍有限,欢迎反馈。 ### English This update adds useful microphone and chat controls, brings Piik to more devices, and fixes several native-sharing and connection-recovery issues. The existing 1.x protocols remain unchanged. #### New and improved - Browser microphones now have a “Noise & echo reduction” toggle. Echo cancellation, noise suppression and automatic gain control are on by default; turn them off when appropriate for music or virtual audio inputs. - Adjust chat-overlay text size and opacity, and export retained messages as TXT. The current session keeps up to 1,000 text messages and clears on page refresh; export first if you want to keep them. - Added Intel Mac and Linux ARM64 App packages, plus Linux ARM64 Server and container images. The website provides architecture selectors and shows the latest release and publication date. - Updated the website demonstration, README screenshots and bilingual guides, clarifying that browser capture can also select windows or screens. A room-code placeholder keeps the bottom bar stable before sharing starts. - Added direct website links to troubleshooting, with steps for browser WebRTC restrictions, campus networks and Windows graphics issues. - The App mode-selection page now shows its free and open-source status, author and contributor credit, and links to the official website and source. #### Fixes - Corrected H.264 format compatibility checks and Windows encoder input-length and output-buffer alignment handling. - Retired stale reconnect tasks and Native receive signals so they cannot continue affecting the current session. - Fixed App reconnection reusing an expired public address. Fresh discovery handles lost probes and stale responses while preserving other working connections. - Fixed UDP socket conflicts between overlapping App media connections so preparing or canceling a replacement preserves the active picture. Closing a connection now cancels unfinished gateway mapping requests. - Connection recovery on passwordless sites no longer incorrectly asks for a site passphrase. - Expired-room and session-termination reasons now use the same TV status indicator before and during sharing, without an extra notice strip. - Corrected Linux native capture timestamps and keyframe time bases. Thanks to Pedro Antonio for [#449](https://github.com/TNTcraftHIM/Piik/pull/449). #### Updating Download the complete archive for your platform, quit the old App, and extract the new package. Windows remains x64-only. macOS packages support Apple silicon and Intel; native capture requires macOS 13 or newer. Linux supports x64 and ARM64 and requires additional [system components](https://github.com/TNTcraftHIM/Piik/blob/main/native/capture/linux/README.md) for native capture. Physical-device coverage on macOS and Linux remains limited; feedback is welcome. ## Attribution Co-authored-by: Pedro Antonio <wrenchwastaken@gmail.com>
309 lines
16 KiB
TypeScript
309 lines
16 KiB
TypeScript
import { createHash } from "node:crypto";
|
|
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { afterAll, describe, expect, it, vi } from "vitest";
|
|
|
|
const { command, notes } = vi.hoisted(() => ({
|
|
command: vi.fn<(program: string, args: string[]) => string>(), notes: vi.fn<() => string>(),
|
|
}));
|
|
vi.mock("node:child_process", () => ({ execFileSync: command }));
|
|
vi.mock("../scripts/release-notes.mjs", () => ({ releaseNotes: notes }));
|
|
vi.mock("node:timers/promises", () => ({ setTimeout: async () => undefined }));
|
|
|
|
const directory = mkdtempSync(join(tmpdir(), "piik-publisher-"));
|
|
const version = "v1.0.1", revision = "a".repeat(40);
|
|
const hash = (value: string | Buffer) => createHash("sha256").update(value).digest("hex");
|
|
for (const target of ["server", "server-linux-arm64", "windows-amd64", "linux-amd64", "linux-arm64", "darwin-arm64", "darwin-amd64"]) {
|
|
const server = target.startsWith("server");
|
|
const artifact = `${target}.${server ? "tar.gz" : "zip"}`;
|
|
writeFileSync(join(directory, artifact), target);
|
|
writeFileSync(join(directory, `${target}.release.json`), JSON.stringify({
|
|
schema: 2, version, revision, artifact, artifactSha256: hash(target),
|
|
target, ...(server ? { manifest: `${target}.manifest.tsv`, manifestSha256: hash("manifest") } : {}),
|
|
}));
|
|
if (server) writeFileSync(join(directory, `${target}.manifest.tsv`), "manifest");
|
|
else writeFileSync(join(directory, `${artifact}.sha256`), `${hash(target)} ${artifact}\n`);
|
|
}
|
|
afterAll(() => rmSync(directory, { recursive: true, force: true }));
|
|
|
|
const packageNames = readdirSync(directory).filter((name) => /\.(zip|tar\.gz)$/.test(name));
|
|
const completeAssets = packageNames.map((name) => ({ name, state: "uploaded" }));
|
|
type Release = { tag_name: string; target_commitish: string; draft: boolean;
|
|
prerelease: boolean; body?: string; assets: typeof completeAssets };
|
|
const release = (draft: boolean): Release => ({
|
|
tag_name: version, target_commitish: revision, draft, prerelease: false, assets: completeAssets,
|
|
});
|
|
|
|
describe("Gitee mirror publication", () => {
|
|
const marker = `<!-- piik-source: ${revision} -->`;
|
|
const api = "https://gitee.com/api/v5/repos/TNTcraftHIM/Piik";
|
|
const download = `https://gitee.com/TNTcraftHIM/Piik/releases/download/${version}/`;
|
|
const sourceAssets = packageNames.map((name) => {
|
|
const bytes = readFileSync(join(directory, name));
|
|
return { name, size: bytes.length, digest: `sha256:${hash(bytes)}`, state: "uploaded" };
|
|
});
|
|
async function mirror(options: { existing?: "pending" | "published" | "unknown"; corrupt?: boolean;
|
|
wrongSource?: boolean; wrongDigest?: boolean; missing?: boolean;
|
|
fault?: { method: string; remaining: number; status: number | "timeout" } } = {}) {
|
|
const mutations: string[] = [];
|
|
const attachments = sourceAssets.map(({ name, size }) => ({ name, size, browser_download_url: download + name }));
|
|
const present = options.existing === "pending" ? attachments.slice(0, 1) : options.missing ? [] : attachments;
|
|
command.mockReturnValue(JSON.stringify({
|
|
...release(false), html_url: `https://github.com/TNTcraftHIM/Piik/releases/tag/${version}`,
|
|
target_commitish: options.wrongSource ? "b".repeat(40) : revision,
|
|
assets: options.wrongDigest ? sourceAssets.map((asset) => ({ ...asset, digest: "sha256:wrong" })) : sourceAssets,
|
|
}));
|
|
vi.stubEnv("GITEE_TOKEN", "fixture-mirror-token");
|
|
vi.stubGlobal("fetch", vi.fn<typeof fetch>(async (input, init) => {
|
|
const url = String(input);
|
|
if (url.startsWith(download)) {
|
|
expect(init?.headers).toBeUndefined();
|
|
const file = url.slice(download.length);
|
|
return new Response(options.corrupt ? "corrupt" : readFileSync(join(directory, file)));
|
|
}
|
|
expect(init?.headers).toHaveProperty("Authorization", "Bearer fixture-mirror-token");
|
|
expect(init?.redirect).toBe("error");
|
|
const path = url.slice(api.length);
|
|
const method = init?.method ?? "GET";
|
|
if (method !== "GET") mutations.push(`${method} ${path}`);
|
|
if (options.fault?.method === method && options.fault.remaining > 0) {
|
|
options.fault.remaining--;
|
|
if (options.fault.status === "timeout") throw new DOMException("Timed out", "TimeoutError");
|
|
return new Response(null, { status: options.fault.status });
|
|
}
|
|
if (path.startsWith("/releases/tags/")) return options.existing
|
|
? Response.json({ id: 42, tag_name: version, body: options.existing === "unknown" ? "unknown" : marker,
|
|
prerelease: options.existing !== "published" }) : new Response(null, { status: 404 });
|
|
if (path === "") return Response.json({ private: false, default_branch: "master" });
|
|
if (path === "/releases" && method === "POST") {
|
|
const body = JSON.parse(String(init?.body));
|
|
expect(body.prerelease).toBe(true);
|
|
expect(body.body).toContain(marker);
|
|
return Response.json({ ...body, id: 42 });
|
|
}
|
|
if (path.includes("/attach_files?") && method === "GET") return Response.json(options.existing ? present : []);
|
|
if (path.endsWith("/attach_files") && method === "POST") {
|
|
const file = (init?.body as FormData).get("file") as File;
|
|
expect(hash(Buffer.from(await file.arrayBuffer()))).toBe(hash(readFileSync(join(directory, file.name))));
|
|
return Response.json(attachments.find((asset) => asset.name === file.name));
|
|
}
|
|
if (path === "/releases/42" && method === "PATCH") {
|
|
const body = JSON.parse(String(init?.body));
|
|
expect(body.prerelease).toBe(false);
|
|
return Response.json({ ...body, id: 42 });
|
|
}
|
|
throw new Error(`Unexpected mirror request: ${method} ${path}`);
|
|
}));
|
|
const argv = process.argv;
|
|
const output = vi.spyOn(console, "log").mockImplementation(() => {});
|
|
process.argv = [process.execPath, "mirror-release.mjs", directory, version, revision];
|
|
vi.resetModules();
|
|
let failure: string | undefined;
|
|
try {
|
|
const script = "../scripts/mirror-release.mjs";
|
|
await import(script);
|
|
} catch (error) {
|
|
failure = error instanceof Error ? error.message : String(error);
|
|
} finally {
|
|
process.argv = argv;
|
|
output.mockRestore();
|
|
vi.unstubAllEnvs();
|
|
vi.unstubAllGlobals();
|
|
}
|
|
return { mutations, failure };
|
|
}
|
|
|
|
it("copies the published bytes, verifies anonymous downloads and marks stable last", async () => {
|
|
const result = await mirror();
|
|
expect(result.failure).toBeUndefined();
|
|
expect(result.mutations[0]).toBe("POST /releases");
|
|
expect(result.mutations.at(-1)).toBe("PATCH /releases/42");
|
|
expect(result.mutations.filter((value) => value.endsWith("/attach_files"))).toHaveLength(sourceAssets.length);
|
|
});
|
|
|
|
it("resumes pending uploads and leaves complete stable releases unchanged", async () => {
|
|
const pending = await mirror({ existing: "pending" });
|
|
expect(pending.failure).toBeUndefined();
|
|
expect(pending.mutations.filter((value) => value.endsWith("/attach_files"))).toHaveLength(sourceAssets.length - 1);
|
|
expect(await mirror({ existing: "published" })).toEqual({ mutations: [], failure: undefined });
|
|
});
|
|
|
|
it.each([503, "timeout"] as const)("retries transient read failures (%s) within a fixed bound", async (status) => {
|
|
const fault = { method: "GET", remaining: 2, status };
|
|
expect((await mirror({ existing: "published", fault })).failure).toBeUndefined();
|
|
expect(fault.remaining).toBe(0);
|
|
fault.remaining = 4;
|
|
expect((await mirror({ fault })).failure).toBeDefined();
|
|
expect(fault.remaining).toBe(1);
|
|
});
|
|
|
|
it("does not repeat forbidden reads or ambiguous writes", async () => {
|
|
const denied = { method: "GET", remaining: 2, status: 403 };
|
|
expect((await mirror({ fault: denied })).failure).toContain("HTTP 403");
|
|
expect(denied.remaining).toBe(1);
|
|
const write = { method: "POST", remaining: 2, status: "timeout" as const };
|
|
const result = await mirror({ fault: write });
|
|
expect(result.failure).toBeDefined();
|
|
expect(result.mutations).toEqual(["POST /releases"]);
|
|
expect(write.remaining).toBe(1);
|
|
});
|
|
|
|
it.each([{ wrongSource: true }, { wrongDigest: true }, { existing: "unknown" as const }])
|
|
("rejects mismatched provenance before mirror writes: %j", async (options) => {
|
|
const result = await mirror(options);
|
|
expect(result.failure).toBeDefined();
|
|
expect(result.mutations).toEqual([]);
|
|
});
|
|
|
|
it("does not publish a corrupt upload or repair a published missing file", async () => {
|
|
const corrupt = await mirror({ corrupt: true });
|
|
expect(corrupt.failure).toMatch(/mismatch/);
|
|
expect(corrupt.mutations).not.toContain("PATCH /releases/42");
|
|
const incomplete = await mirror({ existing: "published", missing: true });
|
|
expect(incomplete.failure).toContain("corrected new version");
|
|
expect(incomplete.mutations).toEqual([]);
|
|
});
|
|
});
|
|
|
|
async function publish(releases: Release[], tag: "absent" | "annotated" | "wrong" | "api-error",
|
|
failureAt?: "notes" | "create" | "upload", inspectBody?: (body: string) => void) {
|
|
const mutations: string[][] = [];
|
|
const copy = "### 更新\n\n- Share `windows` and $literal text.\n";
|
|
let notesPath: string | undefined;
|
|
notes.mockReset().mockImplementation(() => {
|
|
if (failureAt === "notes") throw new Error("Missing release notes");
|
|
return copy;
|
|
});
|
|
let published = releases.some((item) => item.tag_name === version && !item.draft);
|
|
command.mockImplementation((_program, args) => {
|
|
if (args[0] === "release") {
|
|
mutations.push(args);
|
|
if (args.includes("--notes-file")) {
|
|
notesPath = args[args.indexOf("--notes-file") + 1];
|
|
const body = readFileSync(notesPath, "utf8");
|
|
if (args[1] === "create") expect(body.startsWith(copy)).toBe(true);
|
|
expect(body).toContain(`<summary>构建与校验 / Build and checksums</summary>`);
|
|
expect(body).toContain(`/commit/${revision})`);
|
|
for (const name of packageNames) {
|
|
expect(body).toContain(`${hash(readFileSync(join(directory, name)))} ${name}\n`);
|
|
}
|
|
expect(body).not.toMatch(/\.release\.json|\.zip\.sha256|\.manifest\.tsv/);
|
|
expect(args).not.toContain("--generate-notes");
|
|
inspectBody?.(body);
|
|
if (failureAt === "create") throw new Error("GitHub create failed");
|
|
}
|
|
if (args[1] === "edit" && args.includes("--draft=false")) published = true;
|
|
if (args[1] === "upload") {
|
|
expect(args.slice(args.indexOf("--clobber") + 1).sort())
|
|
.toEqual(packageNames.map((name) => join(directory, name)).sort());
|
|
if (failureAt === "upload") throw new Error("GitHub upload failed");
|
|
}
|
|
return "";
|
|
}
|
|
if (args[1].includes("/matching-refs/")) {
|
|
if (tag === "api-error") throw new Error("GitHub lookup failed");
|
|
return JSON.stringify(tag === "absent" && !published ? [] : [{
|
|
ref: `refs/tags/${version}`, object: tag === "annotated"
|
|
? { type: "tag", sha: "c".repeat(40) }
|
|
: { type: "commit", sha: tag === "wrong" ? "b".repeat(40) : revision },
|
|
}]);
|
|
}
|
|
if (args[1].includes("/git/tags/")) return JSON.stringify({ object: { type: "commit", sha: revision } });
|
|
if (args[1].includes("/releases?")) return releases.map((item) => JSON.stringify(item)).join("\n");
|
|
throw new Error(`Unexpected command: ${args.join(" ")}`);
|
|
});
|
|
const argv = process.argv;
|
|
const exited = Symbol("successful exit");
|
|
const exit = vi.spyOn(process, "exit").mockImplementation(() => { throw exited; });
|
|
const output = vi.spyOn(process.stdout, "write").mockReturnValue(true);
|
|
process.argv = [process.execPath, "publish-release.mjs", directory, version, revision];
|
|
vi.resetModules();
|
|
let failure: string | undefined;
|
|
try {
|
|
const script = "../scripts/publish-release.mjs";
|
|
await import(script);
|
|
} catch (error) {
|
|
if (error !== exited) failure = error instanceof Error ? error.message : String(error);
|
|
} finally {
|
|
process.argv = argv;
|
|
exit.mockRestore();
|
|
output.mockRestore();
|
|
if (notesPath) expect(existsSync(notesPath)).toBe(false);
|
|
}
|
|
return { failure, mutations };
|
|
}
|
|
|
|
describe("publisher recovery", () => {
|
|
it.each(["wrong", "api-error"] as const)("stops before mutations for %s tag lookup", async (tag) => {
|
|
const result = await publish([release(true)], tag);
|
|
expect(result.failure).toMatch(/different source revision|lookup failed/);
|
|
expect(result.mutations).toEqual([]);
|
|
});
|
|
|
|
it("accepts annotated tags and preserves a newer stable release when resuming an older draft", async () => {
|
|
const result = await publish([release(true), { ...release(false), tag_name: "v1.1.0" }], "annotated");
|
|
expect(result.failure).toBeUndefined();
|
|
expect(result.mutations.find((args) => args.includes("--draft=false"))).toContain("--latest=false");
|
|
});
|
|
|
|
it("refreshes draft checksums after rebuilding the same SHA while retaining reviewed prose", async () => {
|
|
let draftBody = "";
|
|
const initial = await publish([], "absent", "upload", body => { draftBody = body; });
|
|
expect(initial.failure).toBe("GitHub upload failed");
|
|
const names = ["windows-amd64.zip", "windows-amd64.release.json", "windows-amd64.zip.sha256"];
|
|
const original = names.map(name => readFileSync(join(directory, name)));
|
|
const oldDigest = hash(original[0]!);
|
|
const newBytes = Buffer.from("rebuilt Windows archive at the same source SHA");
|
|
const newDigest = hash(newBytes);
|
|
try {
|
|
writeFileSync(join(directory, names[0]!), newBytes);
|
|
writeFileSync(join(directory, names[1]!), JSON.stringify({
|
|
...JSON.parse(original[1]!.toString()), artifactSha256: newDigest,
|
|
}));
|
|
writeFileSync(join(directory, names[2]!), `${newDigest} ${names[0]}\n`);
|
|
const reviewed = `Owner-edited introduction\n\n${draftBody}\nOwner-edited final note`;
|
|
let updated = "";
|
|
const resumed = await publish([{ ...release(true), body: reviewed }], "annotated", undefined,
|
|
body => { updated = body; });
|
|
expect(resumed.failure).toBeUndefined();
|
|
expect(notes).not.toHaveBeenCalled();
|
|
expect(updated).toBe(reviewed.replace(oldDigest, newDigest));
|
|
expect(updated.match(/piik-build-checksums:start/g)).toHaveLength(1);
|
|
const published = await publish([{ ...release(false), body: reviewed }], "annotated");
|
|
expect(published).toEqual({ failure: undefined, mutations: [] });
|
|
} finally {
|
|
names.forEach((name, index) => writeFileSync(join(directory, name), original[index]!));
|
|
}
|
|
});
|
|
|
|
it("rejects ambiguous draft checksum sections before modifying a release", async () => {
|
|
const result = await publish([{ ...release(true), body: "Reviewed text\n<!-- piik-build-checksums:start -->" }], "annotated");
|
|
expect(result.failure).toContain("ambiguous");
|
|
expect(result.mutations).toEqual([]);
|
|
});
|
|
|
|
it("creates a new release without a pre-existing tag and verifies the resulting tag", async () => {
|
|
const result = await publish([], "absent");
|
|
expect(result.failure).toBeUndefined();
|
|
expect(result.mutations.find((args) => args[1] === "create")).toContain(revision);
|
|
expect(result.mutations.find((args) => args[1] === "edit")).toContain("--latest=true");
|
|
});
|
|
|
|
it("rejects missing public copy before writes and removes temporary notes after a failed create", async () => {
|
|
expect(await publish([], "absent", "notes")).toEqual({ failure: "Missing release notes", mutations: [] });
|
|
const failed = await publish([], "absent", "create");
|
|
expect(failed.failure).toBe("GitHub create failed");
|
|
expect(failed.mutations).toHaveLength(1);
|
|
expect(failed.mutations[0][1]).toBe("create");
|
|
});
|
|
|
|
it("leaves complete published releases unchanged and rejects incomplete published releases", async () => {
|
|
const complete = await publish([release(false)], "annotated");
|
|
expect(complete).toEqual({ failure: undefined, mutations: [] });
|
|
const incomplete = await publish([{ ...release(false), assets: completeAssets.slice(1) }], "annotated");
|
|
expect(incomplete.failure).toContain("publish a new version");
|
|
expect(incomplete.mutations).toEqual([]);
|
|
});
|
|
});
|