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]>
245 lines
20 KiB
Gherkin
245 lines
20 KiB
Gherkin
@spec
|
||
Feature: raea games as playable ads, exported for every ad network from the TSX that renders the video ad
|
||
Shane, 2026-10-29: "lets build a playables feature and explore how we can optimize or help raea agents build for
|
||
playables specifically as well as explore the export options included with it". A playable ad is a 15-60 second
|
||
mini-game served in place of a video ad, inside other apps' WebViews; it ends on a card that opens the store. Bevy
|
||
stays the engine for games (docs/web-export.md is raea's own web build); a playable is an export of a game, drawn by
|
||
a light web renderer on the same scene contract, because Bevy's renderer doesn't fit an ad (PA0b). The code is
|
||
sdk/playable (raea/playable for authors, the browser host, the export tools); the example is
|
||
examples/playables/brick-rush.tsx.
|
||
|
||
Background:
|
||
Given the networks that take advertiser playables in 2026, read from each network's own spec on 10-29
|
||
| network | package | cap | install call | also |
|
||
| AppLovin | one HTML, all inlined (base64/122) | 5 MB | mraid.open(url) | MRAID 2.0; timer starts at the first touch |
|
||
| Unity Ads | one index.html, inlined, minified | 5 MB | mraid.open(url) | MRAID 3.0 injected by the webview; start on ready + viewable, pause when not; both orientations |
|
||
| Google | ZIP, index.html, at most 512 files | 5 MB | ExitApi.exit() | exitapi.js and <meta name="ad.orientation"> in the head; billed per engagement |
|
||
| Meta | one HTML with data URIs, or ZIP | 5 MB | FbPlayableAd.onCTAClick() | no mraid.js; ZIP at most 100 files (blogs that say 2 MB are out of date) |
|
||
| Moloco | one HTML with data URIs, no ZIP | 5 MB | FbPlayableAd.onCTAClick() | mraid.js banned |
|
||
| Mintegral | ZIP: a folder and a page of one name | 5 MB | window.install() | gameReady() when loaded, gameStart from the network, gameEnd() when over |
|
||
| TikTok | ZIP, index.html + config.json | 5 MB zipped | window.openAppStore() | their playable-sdk.js before the game's script; {"playable_orientation": 0/1/2}; no mraid.js |
|
||
| Liftoff | one HTML, or ZIP with one folder | 5 MB | Liftoff.open() | relative paths only |
|
||
And every network refuses a network request, a redirect without a tap, and sound before the first touch
|
||
And ironSource's own network closed on 2026-04-30 (its traffic is Unity LevelPlay's)
|
||
|
||
Rule: Settled questions
|
||
|
||
Scenario: PA0a. What a raea playable is
|
||
Given a game written as any raea game is: React TSX, its state a pure fold of input (useGameState), its 3D the
|
||
SDK's components (which render data-3d elements, the contract the native engine reads)
|
||
Then the same file renders with `raea render` as the video ad (no one touches it, so it plays itself) and exports
|
||
with `raea playable` as a playable for each network
|
||
And it imports raea/playable for the store: <EndCard show={over}> when the game is over, <InstallButton> anywhere,
|
||
or install() from a tap; outside an export install() does nothing
|
||
And it registers a portrait and a landscape composition when it can (the host plays the one nearest the screen;
|
||
a single one is letterboxed, and Unity, AppLovin, Moloco and Mintegral want both)
|
||
|
||
Scenario: PA0b. Bevy's renderer stays out of ads; a light web renderer draws them (measured 10-29)
|
||
Given brick-rush's scene (24 cuboids, paddle, ball, a shadowed directional light) in plain Bevy 0.20 for
|
||
wasm32 (opt-level z, fat LTO, wasm-opt -Oz), next to the three.js export of the same game
|
||
| build | wasm | one HTML (base64) | zipped |
|
||
| Bevy, default features | 23.3 MB | 31.3 MB | 7.4 MB |
|
||
| Bevy, the features raea-render turns on | 21.5 MB | 28.7 MB | 6.9 MB |
|
||
| Bevy, only what the scene needs (WebGL2) | 12.3 MB | 16.5 MB | 3.7 MB |
|
||
| Bevy, only what the scene needs (WebGPU) | 10.8 MB | 14.6 MB | 3.1 MB |
|
||
| Bevy logic only (App, ECS, Transform; no renderer) | 0.55 MB | 0.74 MB | 0.2 MB |
|
||
| sdk/playable: React + three.js + the game | - | 0.79 MB | 0.22 MB |
|
||
And stored gzipped inside the page (DecompressionStream, in every WebView since 2023) the stripped WebGL2 build
|
||
is 4.99 MB as base64: under 5 MB with nothing left for raea's own crates, the game or its assets (brotli: 3.4 MB,
|
||
but older WebViews can't decompress brotli)
|
||
And first frame served from localhost: Bevy 1.9 s, three.js 0.66 s; at 4x CPU throttle 3.2 s and 1.5 s
|
||
Then the renderer (wgpu, naga, bevy_pbr) is about 95% of Bevy on the web: logic alone is small
|
||
And the industry does the same: Unity Playworks (ex-Luna) never ships Unity's WebGL build; it converts the game's
|
||
C# to JavaScript and runs it on its own ~650 KB playable engine; PlayCanvas's engine is ~1.2 MB
|
||
And so a playable is drawn by a light WebGL2 renderer on raea's scene contract, its look held to the native
|
||
engine's by a parity check (PA9), its shading moving toward Bevy's own (PA10, PA11); Bevy's logic may come along
|
||
as wasm (PA12); Bevy wasm stays the path for raea's uncapped web export (docs/web-export.md)
|
||
And WebGPU is on by default in iOS 26's WKWebView and reported in Android WebView, but a playable targets WebGL2
|
||
for reach
|
||
|
||
Rule: Built 10-29
|
||
|
||
@done
|
||
Scenario: PA1. The browser host
|
||
Then sdk/playable/src/host/main.tsx mounts the registered composition nearest the screen's shape on a stage
|
||
scaled uniformly into the screen, steps a Clock 1/fps at a time off requestAnimationFrame with the person's
|
||
input recorded per frame as live entries (input.ts: keys, the primary pointer, every finger, in composition
|
||
px), and draws the page's data-3d parts with three.js under the page (scene.ts), the page's background behind
|
||
the 3D becoming its clear colour
|
||
And it starts when the network says the ad is viewable, pauses while it isn't, stops stepping when the game's
|
||
EndCard shows, and at the composition's last frame shows its own EndCard
|
||
And the status: brick-rush plays in headless mobile Chrome in portrait and landscape; a drag moves the paddle; three
|
||
misses show "So close!"; a tap on the card fires end then install (tools/check.ts, PLAY_SECONDS=25)
|
||
|
||
@done
|
||
Scenario: PA2. Each network's start, pause, store and end calls
|
||
Then sdk/playable/src/network.ts is built with the network's name (__RAEA_NETWORK__) and the store links, and maps
|
||
whenReady, install and end onto the table in the Background (MRAID's ready/viewableChange; Mintegral's
|
||
gameReady, gameStart, gameEnd; the store call per network; preview does nothing)
|
||
|
||
@done
|
||
Scenario: PA3. raea/playable for authors
|
||
Then install(), end(), <EndCard> (the whole card opens the store; end() when it first shows) and <InstallButton>,
|
||
plain page elements, so a native render draws them as the playable does
|
||
|
||
@done
|
||
Scenario: PA4. The lint: what a playable can't have, refused before it is bundled
|
||
Then `raea playable` (apps/playable lint.rs, with sdk/playable/src/export/walk.ts run by `raea run`) renders each
|
||
composition at 12 frames through its length and refuses a 3D kind the host doesn't draw (PLAYABLE_KINDS in
|
||
host/kinds.ts), staticFile, URLs, fetch/XHR/WebSocket, modules that need
|
||
the native engine, and <Video>/<Audio> until PA6; it notes a missing raea/playable import and a single
|
||
orientation
|
||
|
||
@done
|
||
Scenario: PA5. One export, every network's package
|
||
Then `raea playable GAME.tsx -o DIR [--networks ...] [--ios URL] [--android URL] [--title T] [--cta T]
|
||
[--orientation O]` lints, bundles one minified script (PA13) and writes each network's page or ZIP, its settings
|
||
in a preamble before the script, checked against its cap
|
||
And the status: brick-rush exports for all nine targets (eight networks and preview) at 916 KB per HTML and 292 KB
|
||
per ZIP (786 and 218 before PA10's tone-mapping table)
|
||
|
||
@done
|
||
Scenario: PA7. A playable played as a phone shows it
|
||
Then sdk/playable/tools/check.ts PAGE.html OUT [WxH] opens it at a phone's size with touch (WebKit since PA7b),
|
||
drags across it, saves screenshots, reads the console and the ad events back, and fails on an exception or a
|
||
network request; CPU_THROTTLE=4 for a slow phone, PLAY_SECONDS to play to the end and tap the card
|
||
|
||
Rule: Made viable again 11-28
|
||
The 11-06 public-first squash took raea/playable and @raea/playable out of the public sdk/tsconfig.base.json (as it
|
||
did raea/body and raea/gen), so every export failed at the lint with "Cannot find module 'raea/playable'"
|
||
|
||
@done
|
||
Scenario: PA4b. The tools resolve the SDK's names themselves
|
||
Then sdk/playable/tools/alias.ts resolves raea, raea/<module> and @raea/<package> from sdk/tsconfig.base.json's
|
||
paths as engine/bundle's script.rs does, plus raea/playable and @raea/playable/*, as a Bun plugin for the bundle
|
||
And the lint's walk (tools/walk.ts) runs bundled after the game instead of imported by Bun's runtime, whose own
|
||
tsconfig paths ("raea/*") catch raea/playable before any plugin
|
||
And a game's own components in a project with no SDK tsconfig bundle as they render (mobile-ads' gates did not)
|
||
And the status 11-28: brick-rush exports for all nine targets (1,431 KB per HTML, 471 KB per ZIP); mobile-ads'
|
||
tiles (1,393 KB) and gates (1,395 KB) export for AppLovin, Google and preview
|
||
|
||
@done
|
||
Scenario: PA7b. The check plays in WebKit
|
||
Given iOS ad WebViews are WebKit, and raea doesn't test in Chrome (Shane 11-15)
|
||
Then tools/check.ts plays the page in Playwright's WebKit (playwright-core 1.64.1, the app's version) at a phone's
|
||
size with real pointer input held over frames, fails on an exception, a network request, an empty page, or an
|
||
end-card tap with no install event; parity.ts draws its still in WebKit too, and tools/chrome.ts is gone
|
||
And a network's own page tags (Google's exitapi.js, TikTok's playable-sdk.js) are stopped but not failed: the ad
|
||
view serves them
|
||
And the status 11-28: brick-rush, tiles and gates play to their end cards, events ["end","install"], no requests
|
||
|
||
Rule: Next
|
||
|
||
Scenario: PA6. Sound in a playable
|
||
Given networks keep sound off until the first touch and most players never turn it on
|
||
Then raea/tone's instruments and the export's generated foley (TokenSynth, SAO) play through Web Audio from data
|
||
URLs after input.onFirstTouch, inside the size budget
|
||
|
||
Scenario: PA8. Fonts inlined
|
||
Given brick-rush's page asks for Inter, which a phone doesn't have (it fell back to a serif in the first check)
|
||
Then the export inlines the subset of each font the page uses, as the native render draws it
|
||
|
||
@done @needs:PA1
|
||
Scenario: PA9. The playable is held to the native render
|
||
Then a parity check renders the same composition frame with `raea render` and in the playable host (headless
|
||
Chrome, scripted input none, so both play themselves), and compares the 3D's colours where both drew a part
|
||
And it fails when they drift past a bar, so the light renderer can't quietly lose the look
|
||
And the status: sdk/playable/tools/parity.ts GAME.tsx COMPOSITION FRAME OUT [BAR] renders the frame with `raea render
|
||
--frame`, opens a preview build at the composition's size with #still=FRAME&comp=ID (the host draws that one frame
|
||
and stops), and compares the pixels the native frame drew over its background: coverage, mean colours, brightness
|
||
and mean difference (0-255), exiting 1 over BAR (default 16); native.png, playable.png and diff.png are kept
|
||
|
||
@done @needs:PA9
|
||
Scenario: PA10. The lighting conversion
|
||
Given the SDK's 3D layer hands lights to the renderer in its own units (r3f intensities converted from Bevy's lux,
|
||
lumens and cd/m²) and Bevy draws with its camera exposure and TonyMcMapface tone mapping
|
||
Then the host converts them so PA9's colours match
|
||
And the status: host/scene.ts turns the SDK's intensities back into Bevy's units (lux 8000, lumens 9e5 over 4π,
|
||
ambient 400 × π) times Bevy's camera exposure (1 / (1.2 · 2^9.7)); host/tonemap.ts draws the 3D into a half-float
|
||
target and maps it through TonyMcMapface, Bevy's own 48³ table (tools/tony.ts reads bevy_core_pipeline's ktx2)
|
||
resampled to 32³ sRGB bytes (98 KB; the 48³ table scored 5.3 for 311 KB more), sampled as tonemapping.wesl does;
|
||
where nothing was drawn it stays transparent over the page's own background
|
||
And the numbers on brick-rush (mean difference / 255, brightness): portrait frame 90 went from 50.2 and 0.688x
|
||
(three.js's units, no exposure) to 5.4 and 0.992x; landscape frame 300 is 9.1 and 0.971x. three.js's built-in
|
||
curves on the converted units scored Reinhard 14.5, Neutral 21.2, AgX 23.3, none 30.4, ACES 37.9; what is left is
|
||
the shading itself (the bricks' side faces a touch darker), PA11's job
|
||
|
||
@needs:PA9
|
||
Scenario: PA11. Bevy's own shading in the light renderer
|
||
Then Bevy's PBR shaders, composed for the pipelines a playable uses, are translated to GLSL ES 3.00 with naga at
|
||
export time, and the light renderer draws with them instead of three.js's own materials
|
||
And the 10-29 trial: Bevy 0.20's shaders are WESL, composed by bevy_shader with wesl 0.6 (defs as feature flags,
|
||
Int/UInt defs in a virtual `constants` package, `bevy_pbr/bevy_core_pipeline` folded to `bevy_core_pipeline`). A
|
||
standalone program doing the same over the registry sources, then naga 30 (validate, GLSL ES 3.00 for WebGL),
|
||
with WebGL2's defs (WEBGL2, NO_ARRAY_TEXTURES_SUPPORT, NO_CUBE_ARRAY_TEXTURES_SUPPORT, SIXTEEN_BYTE_ALIGNMENT,
|
||
AVAILABLE_STORAGE_BUFFER_BINDINGS=0, MAX_CASCADES_PER_LIGHT=1, PER_OBJECT_BUFFER_BATCH_SIZE=93 for the 176-byte
|
||
Mesh in 16 KB) and the mesh pipeline's for a plain forward StandardMaterial mesh with TonyMcMapface in the shader:
|
||
| shader | GLSL ES 3.00 | gzip | in Chrome's WebGL2 |
|
||
| bevy_pbr::render::pbr frag | 1,703 lines, 88 KB | 16 KB | compiles (29 ms) |
|
||
| bevy_pbr::render::mesh vert | 175 lines, 6.8 KB | 1.7 KB| compiles; the pair links (551 ms) |
|
||
| bevy_pbr::prepass (shadows) | 150 lines, 5.5 KB, vertex | | translated, not linked yet |
|
||
And what that leaves: nothing has been drawn with them. The program binds 7 textures (4 material maps, the point
|
||
and directional shadow maps, the Tony LUT) and 11 uniform blocks the host would fill as Bevy's render world does:
|
||
View (784 B), Lights (2,176 B), the cluster offsets, index lists and clustered lights (16 KB each, so the host
|
||
clusters lights on the CPU as Bevy does on WebGL2), the StandardMaterial (192 B), the Mesh batch and Globals.
|
||
That packing, and the shadow passes, are PA11's real work; the shaders themselves come over unchanged
|
||
|
||
Scenario: PA12. Bevy systems in a playable
|
||
Given Bevy's logic alone is 0.2 MB gzipped as wasm (PA0b)
|
||
Then a game whose rules are Rust (raea/ecs's world, behind the ecs.* native calls) runs them in wasm in the
|
||
playable, its world drawn by the light renderer
|
||
|
||
@done
|
||
Scenario: PA13. `raea playable`
|
||
Then the export is a raea CLI verb (apps/playable) on raea's own bundler, in process: engine/bundle gained
|
||
`minify` (Rolldown's minifier), `inline` (inline.rs: pictures, sounds, fonts and .glb as data URLs, a .bin as a
|
||
Uint8Array) and package-folder aliases (`--alias three/=DIR`, three.js from the project's node_modules, else
|
||
raea's own)
|
||
And the lint's walk runs as `raea run` in a process of its own; tools/playable.sh, bundle.ts, lint.ts, walk.ts,
|
||
alias.ts and chrome.ts are gone, and Bun is needed only for check.ts, parity.ts and tony.ts
|
||
And the status 11-28: brick-rush writes all nine targets in 7 s (1,384 KB per HTML, 464 KB per ZIP), mobile-ads'
|
||
tiles (1,345 KB) and gates (1,347 KB) export, and all play in WebKit, the Google and TikTok packages included;
|
||
a game with staticFile is refused with the reason first
|
||
And fonts travel as pictures do: an imported .ttf, .otf, .woff or .woff2 is its path in a native render and a data
|
||
URL in a playable, named in an @font-face; <EndCard> takes font, color and button for a brand's own card
|
||
|
||
Scenario: PA14. Agents writing playables
|
||
Then the raea skill says how a playable is shaped (hook, a hand until the first touch, a fail moment, the end card
|
||
within 30-60 s, both orientations), what the lint refuses, and how to check one (tools/check.ts)
|
||
And the guide is sdk/guides/craft/motion/playable.md (`raea guide playable`, copied into the skill's motion/), and
|
||
SKILL.md routes "a playable ad" to it
|
||
|
||
Scenario: PA15. A 2D playable carries no three.js
|
||
Given 11-28's tiles bundle: three.js 924 KB of 1,393 KB, react-dom 178 KB, for a game that draws no 3D
|
||
Then the export builds the host without the three.js scene when the lint finds no 3D kind (about 470 KB a page)
|
||
|
||
Scenario: PA16. Playables in the review (raea cloud and the desktop)
|
||
Given the review's own player (raea-platform board-simple review.js PLAYER_DRAWS) is the one view of a shown file
|
||
in raea cloud and in desktop v3, and a playable is one HTML page that loads nothing
|
||
Then a "playable" kind is drawn by that player: the preview page in a sandboxed iframe (allow-scripts only) inside
|
||
a phone frame, portrait and landscape, restarted from the stage's own button
|
||
And the host's ad events (ready, viewable, end, install) show beside it, so a reviewer sees the store tap fire
|
||
And each network's package, its size against the cap, is a download under it, and pins and notes work as on a video
|
||
And `raea show GAME.tsx --playable` exports the preview and shows it as that kind (`raea show PAGE.html` for a page
|
||
already exported); host/show.ts refuses .html today
|
||
# Status 11-28: built. Cloud: raea-platform #99 (merged into #97's oux-audit-1128) and #101: the playable kind
|
||
# (a delivered .html), its 9:16 card, the phone either way up with Restart, the events (ready, viewable,
|
||
# hidden, first touch, end card, store opened), and the network packages folded under it as downloads, red
|
||
# past 5 MB. Shane 11-28: the page plays on a domain of its own: play.raea.io, live 11-28 (#105, #106:
|
||
# PLAY_HOST, harness/play.ts: sandbox allow-scripts, 'wasm-unsafe-eval', network off, no-transform, framed by
|
||
# app.raea.cloud, api.raea.cloud and the desktop's local port). Checked live: the ACANA export uploaded, played
|
||
# from play.raea.io in a sandboxed frame in WebKit, ready and touch posted, the bytes as exported.
|
||
# Desktop: raea-feed #124: `raea show PAGE.html` posts a play item with a page, /host/playable serves it under
|
||
# the same policy, Playable.tsx draws it with pins. `raea show GAME.tsx --playable` exports the preview first
|
||
# (engine/cli show.ts, native.ts). Checked: the real ACANA export served under the policy runs clean in WebKit.
|
||
|
||
Scenario: PA17. Video ad and playable side by side
|
||
Then one shown game is both: its `raea render` (the video ad, played by its own hand) and its playable, one
|
||
project in the review, so a creative test brief gets both formats from one file
|
||
|
||
Scenario: PA18. brick-rush plays live in the native engine
|
||
Given bench/live-3d/corpus.sh skips brick-rush: under RAEA_LIVE3D_CHECK it panics on frame 1, because the fast
|
||
rows (runtime/scene/src/live.rs) carry the sun's rotation and the full rows don't
|
||
Then the fast and full rows agree on a light's transform, and brick-rush plays live and leaves the corpus's skips
|
||
|