wai-rs gains the feature floor (the mandatory floor of SPEC 5: PNG, FLAC and zstd, decoded with no system codec library) and quickstart (the floor, and the receipt checks hello and verify run). The wai command line gains four verbs, one module each, named in one table (dx::VERBS): - hello: name, dispatch, rebuild and receipt on a picture made here, the receipt laid out as http-delivery 8 lays receipts beside an object; - create: a new project from one of the examples, whose files the binary holds; tests/cli_dx.rs holds them to wai/examples/ byte for byte; - dev: the relay, the room service and the room page on one loopback origin, as a production front serves them; --check checks each piece through it; - verify: the receipt indexes under a directory, checked offline. The project file a template writes, wai.json, is read in one place (dx/project.rs). wai/examples/ holds video-room, watch-together, messaging, encoder-ingest, package-and-deliver, verify-receipts, apple-app, android-app and remote-desktop, each with a README and a test that runs it through wai create and wai dev. wai/quickstart/ builds the room client and the archive that holds wai, the relay, the room service, the remote host and the packager. Co-Authored-By: Claude Opus 5.5 <[email protected]>
46 lines
2.5 KiB
JavaScript
46 lines
2.5 KiB
JavaScript
// The video-room example, as a person runs it: `wai create` makes the project, `wai dev` runs
|
|
// it, and two browsers open its page and press Join. Each must receive, verify and decode the
|
|
// other's video and audio, and the page's own line must count both present.
|
|
//
|
|
// node wai/examples/video-room/test/video-room.test.mjs
|
|
import { check, create, dev, dump, finish, frame, launch, open, STEP, tmpdir, until } from "../../../quickstart/test/lib.mjs";
|
|
|
|
const out = tmpdir("video-room");
|
|
const dir = await create("video-room", out);
|
|
const d = await dev(dir);
|
|
const browser = await launch();
|
|
const pages = [];
|
|
try {
|
|
const enter = async (name) => {
|
|
const p = await open(browser, `${d.url}/`, name);
|
|
pages.push(p);
|
|
const f = await frame(p, "/room/");
|
|
await until(`${name}: the room page ready`, STEP, () => f.evaluate(() => window.roomTest && window.roomTest.state && window.roomTest.state.phase === "idle"), 200);
|
|
await f.click("#join");
|
|
const s = await until(`${name}: publishing`, STEP, async () => { const x = await f.evaluate(() => window.roomTest.snapshot()); if (x.errors.length) throw new Error(x.errors[0]); return x.phase === "publishing" && x; }, 250);
|
|
return { p, f, me: s.me.principal };
|
|
};
|
|
const A = await enter("alice");
|
|
const B = await enter("bob");
|
|
for (const [x, other] of [[A, B.me], [B, A.me]]) {
|
|
const t = await until(`${x.p.name} decodes the other`, STEP * 2, async () => {
|
|
const s = await x.f.evaluate(() => window.roomTest.snapshot());
|
|
if (s.errors.length) throw new Error(s.errors[0]);
|
|
const t = s.subs[other];
|
|
return t && t.video.decoded >= 30 && t.audio.decoded >= 50 && t;
|
|
}, 500);
|
|
check(`${x.p.name}'s page receives, verifies and decodes the other's camera and microphone`, t.video.refused === 0, `${t.video.verified} video objects verified, ${t.video.decoded} decoded; ${t.audio.decoded} audio frames`);
|
|
}
|
|
const line = await until("the page's own line counts two present", STEP, async () => {
|
|
const v = await A.p.evaluate(() => ({ n: document.getElementById("who").dataset.present, text: document.getElementById("who").textContent }));
|
|
return v.n === "2" && v;
|
|
}, 500);
|
|
check("the page's own script reads the room service's API and counts two present", true, line.text);
|
|
} catch (e) {
|
|
check("the example ran to its end", false, (e && e.stack || String(e)).split("\n").slice(0, 3).join(" | "));
|
|
} finally {
|
|
dump(pages, out);
|
|
await browser.close().catch(() => {});
|
|
await d.stop();
|
|
}
|
|
finish("video-room");
|