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
raea render PAGE.html: the HTML runtime from raea's files, bundled in process
Leonardo Gonzalez6e7bbad1576d
diff --git a/Cargo.lock b/Cargo.lockindex 1ca4c0c6..bd720b54 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -14128,8 +14128,10 @@ dependencies = ["bevy","raea-bevy-world","raea-core-wire",+ "raea-io-home","raea-io-media","raea-io-net",+ "raea-runtime-bundle","raea-runtime-jsengine","serde","serde_json",diff --git a/runtime/js/Cargo.toml b/runtime/js/Cargo.tomlindex 53620447..f358e713 100644--- a/runtime/js/Cargo.toml+++ b/runtime/js/Cargo.toml@@ -32,4 +32,8 @@ raea-runtime-jsengine = { path = "../jsengine" }raea-io-media = { path = "../../io/media", default-features = false, optional = true }# webaudio's samples across the wirebase64 = "0.22"+# the HTML runtime bundled in process (html_page.rs): raea's files where an install or this checkout has them, and+# raea-bundle's library loaded beside the binary+raea-io-home = { path = "../../io/home" }+raea-runtime-bundle = { path = "../bundle" }diff --git a/runtime/js/js/build.ts b/runtime/js/js/build.tsdeleted file mode 100644index 585f84b1..00000000--- a/runtime/js/js/build.ts+++ /dev/null@@ -1,40 +0,0 @@-// A TSX entry bundled for raea-runtime-js: `bun build.ts ENTRY OUT.js UI_SRC FALLBACK_MODULES` makes one IIFE of the entry,-// @raea/ui (resolved to UI_SRC, sdk/ui/src) and React. Bare imports resolve from the entry's own node_modules first,-// then FALLBACK_MODULES (raea's sdk/react/js/node_modules), so an entry folder needs no install of its own.-import { dirname, join } from "node:path";--const [entry, out, ui, fallback] = process.argv.slice(2);-if (!entry || !out || !ui) {- console.error("usage: bun build.ts ENTRY OUT.js UI_SRC [FALLBACK_MODULES]");- process.exit(2);-}-const b = await Bun.build({- entrypoints: [entry],- target: "browser",- format: "iife",- minify: { syntax: true },- define: { "process.env.NODE_ENV": '"production"' },- plugins: [- {- name: "raea-runtime-js-modules",- setup(b) {- // @raea/ui's subpaths (./react, ./wire, ./platform ...) from UI_SRC- b.onResolve({ filter: /^@raea\/ui(\/.*)?$/ }, (a) => ({ path: join(ui, (a.path.slice("@raea/ui/".length) || "index") + ".ts") }));- // React and friends: the entry's own, else the fallback's- b.onResolve({ filter: /^(react|react-dom|react-reconciler|scheduler)(\/.*)?$/ }, (a) => {- try {- return { path: Bun.resolveSync(a.path, dirname(a.importer || entry)) };- } catch {- if (!fallback) throw new Error(`${a.path}: not installed beside ${entry}`);- return { path: Bun.resolveSync(a.path, fallback + "/") };- }- });- },- },- ],-});-if (!b.success) {- console.error(b.logs.map((l) => String(l)).join("\n"));- process.exit(1);-}-await Bun.write(out, await b.outputs[0].text());diff --git a/runtime/js/src/bundle.rs b/runtime/js/src/bundle.rsdeleted file mode 100644index e3f36127..00000000--- a/runtime/js/src/bundle.rs+++ /dev/null@@ -1,36 +0,0 @@-//! A TSX entry bundled with bun (js/build.ts): one IIFE of the entry, @raea/ui and React, ready for any engine.-//! `BEVY_TSX_UI` names @raea/ui's source folder and `BEVY_TSX_MODULES` the node_modules to fall back to; both default-//! to raea's (sdk/ui/src, sdk/react/js/node_modules beside this crate).--use std::path::{Path, PathBuf};-use std::time::Instant;--fn here() -> PathBuf {- PathBuf::from(env!("CARGO_MANIFEST_DIR"))-}--/// The bundle of `entry`, as JS.-pub fn build(entry: &Path) -> Result<String, String> {- let ui = std::env::var("BEVY_TSX_UI").map(PathBuf::from).unwrap_or_else(|_| here().join("../../sdk/ui/src"));- let modules = std::env::var("BEVY_TSX_MODULES").map(PathBuf::from).unwrap_or_else(|_| here().join("../../sdk/react/js/node_modules"));- let entry = entry.canonicalize().map_err(|e| format!("{}: {e}", entry.display()))?;- let out = std::env::temp_dir().join(format!("raea-runtime-js-{}-{}.js", std::process::id(), entry.file_stem().and_then(|s| s.to_str()).unwrap_or("entry")));- let t = Instant::now();- let r = std::process::Command::new("bun")- .arg(here().join("js/build.ts"))- .arg(&entry)- .arg(&out)- .arg(&ui)- .arg(&modules)- .output()- .map_err(|e| format!("bun (is it installed?): {e}"))?;- if !r.status.success() {- return Err(format!("bun build {}: {}", entry.display(), String::from_utf8_lossy(&r.stderr)));- }- let code = std::fs::read_to_string(&out).map_err(|e| e.to_string())?;- let _ = std::fs::remove_file(&out);- if crate::trace().is_some() {- eprintln!("raea-runtime-js: bundled {} in {} ms ({} KB)", entry.display(), t.elapsed().as_millis(), code.len() / 1024);- }- Ok(code)-}diff --git a/runtime/js/src/html_page.rs b/runtime/js/src/html_page.rsindex 01ee7df3..4d1624e2 100644--- a/runtime/js/src/html_page.rs+++ b/runtime/js/src/html_page.rs@@ -50,12 +50,19 @@ pub fn read_answer(dir: &Path, args: &Value) -> R<Value> {Ok(out)}-/// The runtime's bundle (sdk/ui/src/html.ts), bundled once a process.+/// The runtime's bundle (sdk/ui/src/html.ts), bundled once a process by raea's own bundler (Rolldown, in process),+/// from raea's files where `raea_io_home` finds them: an install's share/raea, else this checkout. `BEVY_TSX_UI` names+/// another sdk/ui/src. (It was bun and this crate's js/build.ts, beside the tree it was built from: a release has+/// neither, so `raea render PAGE.html` failed installed.)pub fn bundle() -> R<String> {static CODE: OnceLock<R<String>> = OnceLock::new();CODE.get_or_init(|| {- let entry = std::env::var("BEVY_TSX_UI").map(PathBuf::from).unwrap_or_else(|_| PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../sdk/ui/src")).join("html.ts");- crate::bundle::build(&entry)+ let ui = std::env::var_os("BEVY_TSX_UI").map(PathBuf::from).unwrap_or_else(|| raea_io_home::home().join("sdk/ui/src"));+ let entry = ui.join("html.ts");+ if !entry.is_file() {+ return Err(format!("{}: the HTML runtime isn't there (BEVY_TSX_UI names another sdk/ui/src)", entry.display()));+ }+ raea_runtime_bundle::inproc::bundle(&entry, json!({})).map(|(js, _css)| js).map_err(|e| format!("the HTML runtime ({}): {e}", entry.display()))}).clone()}diff --git a/runtime/js/src/lib.rs b/runtime/js/src/lib.rsindex b52da672..10194c3a 100644--- a/runtime/js/src/lib.rs+++ b/runtime/js/src/lib.rs@@ -8,7 +8,6 @@//! Its bevy_ui host (elements as bevy_ui nodes, with their controls, svg, layout snapshot and painter) went in the//! overhaul (docs/overhaul.md, 10-27): no app mounted it after docs/blitz-bevy.feature B5d, since every page is Blitz's.-pub mod bundle;pub mod calls;pub mod html_page;pub mod js;