Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
// A playable played in headless WebKit, as an iPhone's ad WebView would show it (docs/playables.feature PA7): the page
// opened at a phone's size, a drag held long enough for the host's per-frame input to see it, its console,
// exceptions and any network request it tried read back, and screenshots saved.
// `bun tools/check.ts PAGE.html OUT_DIR [WxH]`; exits 1 on a page error, a request, or a page that never drew.
// PLAY_SECONDS=N plays on, then taps the end card (and the check fails if no install event came back).
// WebKit, not Chrome: iOS ad WebViews are WebKit, and raea doesn't test in Chrome.
import { mkdirSync } from "node:fs";
import { resolve } from "node:path";
import { webkit } from "playwright-core";
const [page, outDir, size = "390x844"] = process.argv.slice(2);
if (!page || !outDir) throw new Error("usage: bun tools/check.ts PAGE.html OUT_DIR [WxH]");
const [W, H] = size.split("x").map(Number);
mkdirSync(outDir, { recursive: true });
const browser = await webkit.launch();
const ctx = await browser.newContext({ viewport: { width: W, height: H }, deviceScaleFactor: 2, hasTouch: true, isMobile: true });
const p = await ctx.newPage();
const logs: string[] = [];
const problems: string[] = [];
p.on("console", (m) => logs.push(`${m.type()}: ${m.text()}`));
p.on("pageerror", (e) => problems.push(`exception: ${e.message}`));
// the scripts a network's own page tags load, which its ad view serves (apps/playable pages.rs): Google's exit API and
// TikTok's playable SDK. They're stopped here like any request, but they aren't the game's.
const NETWORK_TAGS = ["https://tpc.googlesyndication.com/pagead/gadgets/html5/api/exitapi.js", "https://sf16-muse-va.ibytedtos.com/obj/union-fe-nc-i18n/playable/sdk/playable-sdk.js"];
await ctx.route("**/*", (r) => {
const u = r.request().url();
if (u.startsWith("file:") || u.startsWith("data:") || u.startsWith("blob:")) return r.continue();
if (!NETWORK_TAGS.includes(u)) problems.push(`network request: ${u}`);
return r.abort();
});
await p.goto(page.startsWith("http") ? page : `file://${resolve(page)}`);
await p.waitForTimeout(1500);
const shot = (name: string) => p.screenshot({ path: resolve(outDir, `${name}.png`) });
// real input: WebKit makes the pointer events the host reads (host/input.ts), each press held over several frames
// (the host samples input once a frame, so a press shorter than a frame is lost)
const press = async (type: "down" | "move" | "up", x: number, y: number) => {
await p.mouse.move(x, y);
if (type === "down") await p.mouse.down();
if (type === "up") await p.mouse.up();
};
await shot("0-start");
await press("down", W * 0.3, H * 0.75);
for (let i = 0; i <= 10; i++) {
await press("move", W * (0.3 + 0.04 * i), H * 0.75);
await p.waitForTimeout(80);
}
await press("up", W * 0.7, H * 0.75);
await shot("1-played");
await p.waitForTimeout(2500);
await shot("2-later");
const more = Number(process.env.PLAY_SECONDS ?? 0);
if (more > 0) {
await p.waitForTimeout(more * 1000);
await shot("3-end");
await press("down", W / 2, H / 2);
await p.waitForTimeout(150);
await press("up", W / 2, H / 2);
await p.waitForTimeout(300);
}
const state = (await p.evaluate(() => ({
canvas: !!document.querySelector("#raea-stage canvas"),
parts: document.querySelectorAll("[data-3d]").length,
page: document.querySelector("#raea-page")?.childElementCount ?? 0,
events: (globalThis as { __raeaAdEvents?: unknown[] }).__raeaAdEvents ?? [],
}))) as { canvas: boolean; parts: number; page: number; events: unknown[] };
console.log(`page: ${JSON.stringify(state)}`);
if (!state.page && !state.parts) problems.push("nothing drew: the game's page is empty");
if (more > 0 && !JSON.stringify(state.events).includes("install")) problems.push("the end card was tapped but no install event came back");
for (const l of logs) console.log(l);
for (const pr of problems) console.log(`PROBLEM: ${pr}`);
await browser.close();
process.exit(problems.length ? 1 : 0);