mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 12:44:11 -10:00
* PA13, PA14: raea playable, and playables in the public engine
Playables move from the private tree into the public engine (Shane 11-28: "public totally part of the engine"):
sdk/playable (raea/playable for authors, the browser host, check.ts, parity.ts, tony.ts), examples/playables and
docs/playables.feature, with raea/playable and @raea/playable back in sdk/tsconfig.base.json.
`raea playable GAME.tsx -o DIR` (apps/playable) replaces the Bun pipeline (playable.sh, bundle.ts, lint.ts, walk.ts,
alias.ts). It lints the source, renders each composition through `raea run` for its shapes and 3D kinds, bundles the
game and the host once with raea's own bundler, and writes each network's page or ZIP against its 5 MB cap.
engine/bundle gains `minify`, `inline` (inline.rs: pictures, sounds, fonts and .glb as data URLs, .bin as a
Uint8Array) and package-folder aliases (`three/=DIR`). brick-rush writes all nine targets in 7 s (1,384 KB a page);
mobile-ads' tiles and gates export; all play in WebKit, the Google and TikTok packages included.
check.ts lets a network's own page tags through; parity.ts draws in WebKit (chrome.ts is gone), 6.8/255 on
brick-rush frame 300. The craft guide motion/playable.md is `raea guide playable`. bench/live-3d skips brick-rush with
its real reason (PA18).
* tools/layers.toml: raea-app-playable in apps (PA13)
* Fonts travel with a playable, and an end card in a brand's type
An imported .ttf, .otf, .woff or .woff2 (and .jpeg) is its path in a native render (runtime/bundle rewrite.rs,
engine/bundle script.rs) and a data URL in a playable (inline.rs), so an @font-face names the same file either way.
<EndCard> takes font, color and button. Made for the real-brand playables in mobile-ads (ACANA, OLIPOP, HelloFresh),
which carry their brands' own type; the guide and docs/playables.feature say how.
* The preview page tells raea's review its ad events (PA16)
Inside a frame, the preview network posts {raeaPlayable: kind} to its parent on install and end, so the review can show
them beside the game.
* PA16 status: the review plays playables (raea-platform #99), on a host of their own
* The preview page tells the review when it's ready, seen or hidden, and the first touch (PA16)
Beside install and end, the preview build inside a frame posts ready (the game started), viewable and hidden (its page
shown or put away) and touch (the player took over from the game's own hand), so the review and the desktop show them.
* PA16 status: built in cloud (raea-platform #99, #101) and desktop (raea-feed #124), and raea show --playable
* raea playable says what the source can't have even when the game won't render for the lint
A fetch or a URL often stops the walk's render too, and the lint answered with the render's end ("lint.ts ended with
exit 1") and dropped the refusals it had found. Now the source's refusals are the answer, and a render that fails
for another reason is named by its error line.
* PA16 status: play.raea.io is live, checked with the ACANA export
* skills: raea-skills main ae81d0f (#135 notes hook, #136 and #137 the playable guide and raea playable in cli.md)
tools/skills.sh gen with a raea built at this branch and the feed app at main: every reference and guide copy matches it.
* raea-cli: export-game and playable dispatched in a line each, as the verbs around them, so the crate stays at the size gate's 2000 lines
* dupes: the playable's copies folded into what they copied
spec is raea-runtime-bundle's own (now pub), inline.rs's base64 is the base64 crate as raea's other crates use it,
the store and card JSON are json!, and the bundle FFI reads minify and inline as it reads z3 and stamps. tools/dupes.sh:
293 exact, 57 near, as allowed.
---------
Co-authored-by: shinyobjectz <[email protected]>
77 lines
3.9 KiB
TypeScript
77 lines
3.9 KiB
TypeScript
// 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);
|