Skip to content

armgit / raea

Public Imported from GitHub
0

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.

H12: app::bundle takes the props its default export is mounted with (WINDOW, SCREEN) in place of two one-line forwarders; the app screens' log read through screen::logged (no new duplicate groups: 292 exact, 59 near)

shinyobjectz80fbde3c58a5
diff --git a/apps/targets/src/native.rs b/apps/targets/src/native.rs
index e281464b..925fe04d 100644
--- a/apps/targets/src/native.rs
+++ b/apps/targets/src/native.rs
@@ -64,7 +64,7 @@ pub fn host(args: &[String]) -> Result<String, String> {
let p = Path::new(a);
if p.extension().is_some_and(|x| x == "tsx" || x == "ts" || x == "jsx") && p.is_file() {
std::fs::create_dir_all(&work).map_err(|e| format!("{}: {e}", work.display()))?;
- let (js, css) = raea_runtime_bundle::inproc::app::bundle(p, &raea_io_home::home())?;
+ let (js, css) = raea_runtime_bundle::inproc::app::bundle(p, &raea_io_home::home(), raea_runtime_bundle::inproc::app::WINDOW)?;
let script = work.join(format!("{}.js", p.file_stem().unwrap_or_default().to_string_lossy()));
std::fs::write(&script, js).map_err(|e| format!("{}: {e}", script.display()))?;
handed.push(script.display().to_string());
diff --git a/apps/targets/src/web.rs b/apps/targets/src/web.rs
index 6d349d2d..365c538e 100644
--- a/apps/targets/src/web.rs
+++ b/apps/targets/src/web.rs
@@ -24,7 +24,7 @@ pub struct Built {
pub fn build(app: &Path, dir: &Path) -> Result<Built, String> {
let app = raea_io_home::plain(app.canonicalize().map_err(|e| format!("{}: {e}", app.display()))?);
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
- let (js, imported) = raea_runtime_bundle::inproc::app::bundle(&app, &raea_io_home::home())?;
+ let (js, imported) = raea_runtime_bundle::inproc::app::bundle(&app, &raea_io_home::home(), raea_runtime_bundle::inproc::app::WINDOW)?;
let folder = app.parent().unwrap_or(Path::new("."));
let tw = raea_runtime_bundle::styles::tailwind(folder)?;
let built = Built { js: dir.join("app.js"), css: dir.join("app.css") };
diff --git a/engine/rune/tests/common/mod.rs b/engine/rune/tests/common/mod.rs
index 85a27a56..112f878b 100644
--- a/engine/rune/tests/common/mod.rs
+++ b/engine/rune/tests/common/mod.rs
@@ -12,7 +12,7 @@ fn home() -> PathBuf {
/// `file`'s script
pub fn script(file: &Path) -> String {
- raea_runtime_bundle_lib::app::bundle(file, &home()).unwrap().0
+ raea_runtime_bundle_lib::app::bundle(file, &home(), raea_runtime_bundle_lib::app::WINDOW).unwrap().0
}
/// tests/apps/`name`
diff --git a/runtime/appscreen/src/lib.rs b/runtime/appscreen/src/lib.rs
index 692f8be8..acb0b53e 100644
--- a/runtime/appscreen/src/lib.rs
+++ b/runtime/appscreen/src/lib.rs
@@ -265,7 +265,7 @@ pub fn build(file: &Path) -> R<(String, String)> {
if !file.is_file() {
return Err(format!("{}: no such module", file.display()));
}
- let (js, imported) = raea_runtime_bundle::inproc::app::bundle_screen(file, &raea_io_home::home())?;
+ let (js, imported) = raea_runtime_bundle::inproc::app::bundle(file, &raea_io_home::home(), raea_runtime_bundle::inproc::app::SCREEN)?;
let tw = raea_runtime_bundle::styles::tailwind(file.parent().unwrap_or(Path::new(".")))?;
Ok((js, format!("{imported}\n{tw}")))
}
diff --git a/runtime/bundle/lib/src/app.rs b/runtime/bundle/lib/src/app.rs
index 2a44fbc7..a7768233 100644
--- a/runtime/bundle/lib/src/app.rs
+++ b/runtime/bundle/lib/src/app.rs
@@ -36,18 +36,17 @@ fn ui(home: &Path) -> serde_json::Value {
m.into()
}
-/// `app` bundled against `home`: its script and the CSS its modules import
-pub fn bundle(app: &Path, home: &Path) -> Result<(String, String), String> {
- bundle_with(app, home, "null")
-}
+/// What an app's default export is given, for `bundle`: nothing, as an app in a window of its own is (it reads the
+/// window)
+pub const WINDOW: &str = "null";
-/// An app screen's module (`<Screen app="kit.tsx">`, docs/blitz-bevy.feature H12) bundled as an app is: its default
-/// export given `{width, height}`, the screen's size (its document's, so one bundle serves a screen of any size)
-pub fn bundle_screen(app: &Path, home: &Path) -> Result<(String, String), String> {
- bundle_with(app, home, "{ width: innerWidth, height: innerHeight }")
-}
+/// What an app screen's module (`<Screen app="kit.tsx">`, docs/blitz-bevy.feature H12) is given: `{width, height}`, the
+/// screen's size (its document's, so one bundle serves a screen of any size)
+pub const SCREEN: &str = "{ width: innerWidth, height: innerHeight }";
-fn bundle_with(app: &Path, home: &Path, props: &str) -> Result<(String, String), String> {
+/// `app` bundled against `home`, its default export mounted with `props` (WINDOW or SCREEN): its script and the CSS its
+/// modules import
+pub fn bundle(app: &Path, home: &Path, props: &str) -> Result<(String, String), String> {
// canonical, and on Windows without canonicalize()'s verbatim \\?\ prefix: Rolldown can't resolve an entry that
// imports a path written with it (T1f: the Windows release check, 11-07)
let app = raea_io_home::plain(app.canonicalize().map_err(|e| format!("{}: {e}", app.display()))?);
diff --git a/runtime/live/src/lib.rs b/runtime/live/src/lib.rs
index 4dd8f50a..17471bab 100644
--- a/runtime/live/src/lib.rs
+++ b/runtime/live/src/lib.rs
@@ -383,7 +383,7 @@ impl Live {
/// What reached the app screens in the last frame stepped, as its input log keeps it (`apps`): a render of the
/// log gives them the same (runtime/page/src/screen.rs).
pub fn app_input(&self) -> Option<serde_json::Value> {
- self.page.app_input()
+ raea_runtime_page::screen::logged(&self.page)
}
}
diff --git a/runtime/page/src/bevy_page.rs b/runtime/page/src/bevy_page.rs
index 1b809618..f3d9d881 100644
--- a/runtime/page/src/bevy_page.rs
+++ b/runtime/page/src/bevy_page.rs
@@ -160,11 +160,6 @@ impl BevyPage {
self.apps.frame = Some((f, fps));
}
- /// What reached the app screens this frame, for the input log (runtime/page/src/screen.rs `logged`).
- pub fn app_input(&self) -> Option<Value> {
- self.apps.r.logged()
- }
-
/// The page drawn and read back: premultiplied RGBA rows, `w` x `h`.
pub fn frame(&mut self) -> R<Vec<u8>> {
self.page.frame()
diff --git a/runtime/page/src/screen.rs b/runtime/page/src/screen.rs
index fdfee08b..93752f55 100644
--- a/runtime/page/src/screen.rs
+++ b/runtime/page/src/screen.rs
@@ -86,6 +86,11 @@ pub fn route(page: &mut crate::BevyPage, engine: &mut raea_render::engine::Engin
}
}
+/// What reached the page's app screens this frame, for the input log (Routed::logged): None when nothing did.
+pub fn logged(page: &crate::BevyPage) -> Option<Value> {
+ page.apps.r.logged()
+}
+
/// The app screens that went let go of: their focus, pointer and failures forgotten, so a screen back again opens
/// fresh. `screens`: each app screen now, its name, size and module.
pub(crate) fn retire(a: &mut Apps, screens: &[(String, u32, u32, String)]) {