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
Layer pass before landing (L1): RAEA_HIDE_LAYERS's page CSS (hidden_css, layer_selector) moved from raea-runtime-bundle, which was over its 2000 lines, to raea-sys-layers (hide.rs); the render manifest's videos and text moved to engine/page motion/manifest.rs (motion.rs was over 500); raea-sys-layers in tools/layers.toml (systems, a facility raea-sys-frame builds on). Copies folded: a part's key from its props is raea_sys_layers::key_from_props (runtime/scene bevy_parts), an env switch set to 1 is raea_io_home::env_on (fresh.rs stamps, apps/game probing), and the ID scene draws a box shadow as its element's layer out to 1.5 deviations past its box (hiding an element hides its shadow) instead of skipping it.
shinyobjectzed0ebd2c0115
diff --git a/Cargo.lock b/Cargo.lockindex 769d3ef0..6cc392dc 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -13611,6 +13611,7 @@ version = "0.1.0"dependencies = ["base64 0.22.1","raea-gpu-device",+ "raea-io-home","raea-io-media","raea-io-net","raea-runtime-export",@@ -14652,6 +14653,7 @@ dependencies = ["raea-io-media","raea-native","raea-runtime-bundle-lib",+ "raea-sys-layers","regex","serde_json","windows-sys 0.61.2",diff --git a/apps/game/Cargo.toml b/apps/game/Cargo.tomlindex 5c40ad80..afd26d8f 100644--- a/apps/game/Cargo.toml+++ b/apps/game/Cargo.toml@@ -23,6 +23,8 @@ raea-runtime-react = { path = "../../runtime/react", default-features = false }raea-runtime-page = { path = "../../runtime/page" }raea-runtime-export = { path = "../../runtime/export" }raea-runtime-live = { path = "../../runtime/live" }+# its switches (env_on)+raea-io-home = { path = "../../io/home" }serde_json = "1"winit = "=0.30.13"raea-gpu-device = { path = "../../gpu/device" }diff --git a/apps/game/src/window.rs b/apps/game/src/window.rsindex 8150698b..2151bf40 100644--- a/apps/game/src/window.rs+++ b/apps/game/src/window.rs@@ -212,7 +212,7 @@ impl ApplicationHandler for Player {}pub(crate) fn probing() -> bool {- std::env::var("RAEA_PLAYER_PROBE").as_deref() == Ok("1")+ raea_io_home::env_on("RAEA_PLAYER_PROBE")}pub(crate) fn windowed(game: Game) -> R<String> {diff --git a/engine/page/src/motion.rs b/engine/page/src/motion.rsindex 53db16e4..6b55d939 100644--- a/engine/page/src/motion.rs+++ b/engine/page/src/motion.rs@@ -17,6 +17,7 @@ use raea_sys_page::ops::{self, Nodes};use raea_sys_page::{Docs, Page, PageImage}; use crate::PagePlugin;mod read;+mod manifest;mod place;type R<T> = Result<T, String>;@@ -357,122 +358,6 @@ impl BlitzPage {Ok((page, subs))}- /// The render manifest's videos and text, as laid out (raea check's clipped, safe-area and reading rules read it):- /// each shown element with a `data-raea-src` (a video: its source, time and box), and each element's own words- /// (its text children's, inline elements' words going to the nearest element up with a box) with that box, its- /// opacity, colour, size, weight and alignment as computed. In document order, as raea-runtime-js's page gave them.- pub fn manifest(&mut self) -> (Vec<serde_json::Value>, Vec<serde_json::Value>) {- use serde_json::json;- use style::computed_values::visibility::T as Visibility;- use style::values::specified::text::TextAlignKeyword;- let docs = self.app.world().non_send::<Docs>();- let Some(doc) = docs.0.get(&self.page) else { return (vec![], vec![]) };- let r = |v: f64| (v * 10.0).round() / 10.0;- let rect = |n: blitz_dom::NodeId| doc.get_client_bounding_rect(n).filter(|b| b.width > 0.0 && b.height > 0.0);- // its own opacity times its parents', 0 when it or one of them isn't shown- let alpha = |n: blitz_dom::NodeId| -> f64 {- let (mut a, mut at) = (1.0f64, Some(n));- while let Some(x) = at {- let Some(node) = doc.get_node(x) else { break };- if node.is_element() {- let Some(s) = node.primary_styles() else { return 0.0 };- if !node.has_boxes() || (x == n && matches!(s.clone_visibility(), Visibility::Hidden | Visibility::Collapse)) {- return 0.0;- }- a *= s.get_effects().opacity as f64;- }- at = node.parent;- }- a- };- // the source stamps (engine/bundle stamp.rs) of the nearest element up from `n` that has them: where the JSX- // is written ("promo.tsx:12:7"), and the uses of the edit's components it was drawn in, nearest first- let stamps = |n: blitz_dom::NodeId, entry: &mut serde_json::Value| {- let mut at = Some(n);- while let Some(x) = at {- let Some(node) = doc.get_node(x) else { break };- if let Some(loc) = node.attr(LocalName::from("data-raea-loc")) {- entry["loc"] = json!(loc);- if let Some(uses) = node.attr(LocalName::from("data-raea-use")).filter(|u| !u.is_empty()) {- entry["use"] = json!(uses.split('|').collect::<Vec<_>>());- }- // its place in a list (its .map()'s key), when it has one- if let Some(idx) = node.attr(LocalName::from("data-raea-idx")) {- entry["index"] = json!(idx);- }- return;- }- at = node.parent;- }- };- let (mut videos, mut text) = (Vec::new(), Vec::new());- let mut owned: Vec<(blitz_dom::NodeId, Vec<String>)> = Vec::new();- // the whole document: a composition's sequences and screens are pages of their own under the root's- let mut stack = vec![doc.root_node().id];- while let Some(n) = stack.pop() {- let Some(node) = doc.get_node(n) else { continue };- if node.is_element() && matches!(node.element_data().map(|e| &*e.name.local), Some("style" | "script")) {- continue;- }- stack.extend(node.children.iter().rev().copied());- if let Some(src) = node.attr(LocalName::from("data-raea-src")) {- let a = alpha(n);- if let (Some(b), true) = (rect(n), a > 0.01) {- let at = node.attr(LocalName::from("data-raea-at")).and_then(|v| v.parse::<f64>().ok()).unwrap_or(0.0);- let mut v = json!({"src": src, "at": at, "box": [r(b.x), r(b.y), r(b.width), r(b.height)], "opacity": (a * 100.0).round() / 100.0});- stamps(n, &mut v);- videos.push(v);- }- continue;- }- if !node.is_text_node() {- continue;- }- let words = node.text_content();- let words = words.trim();- if words.is_empty() {- continue;- }- // an inline element (a <span> around a caption word) has no box of its own: its words belong to the- // nearest element up that has one- let mut up = node.parent;- while let Some(p) = up {- let inline = doc.get_node(p).and_then(|x| x.primary_styles()).is_some_and(|s| s.clone_display().outside() == style::values::specified::box_::DisplayOutside::Inline);- if !inline && rect(p).is_some() {- break;- }- up = doc.get_node(p).and_then(|x| x.parent);- }- let Some(owner) = up else { continue };- if node.parent.is_none_or(|p| alpha(p) <= 0.01) {- continue;- }- match owned.iter_mut().find(|(o, _)| *o == owner) {- Some((_, ws)) => ws.push(words.to_string()),- None => owned.push((owner, vec![words.to_string()])),- }- }- for (owner, words) in owned {- let (Some(b), Some(node)) = (rect(owner), doc.get_node(owner)) else { continue };- let Some(s) = node.primary_styles() else { continue };- let c = s.clone_color().to_color_space(style::color::ColorSpace::Srgb);- let [cr, cg, cb] = [c.components.0, c.components.1, c.components.2].map(|v| (v.clamp(0.0, 1.0) * 255.0).round());- let ca = c.alpha;- let color = if ca >= 1.0 { format!("rgb({cr}, {cg}, {cb})") } else { format!("rgba({cr}, {cg}, {cb}, {})", (ca * 1000.0).round() / 1000.0) };- let font = s.get_font();- let align = match s.clone_text_align() {- TextAlignKeyword::Center | TextAlignKeyword::MozCenter => "center",- TextAlignKeyword::Right | TextAlignKeyword::End | TextAlignKeyword::MozRight => "right",- TextAlignKeyword::Justify => "justify",- _ => "left",- };- let mut t = json!({"text": words.join(" "), "box": [r(b.x), r(b.y), r(b.width), r(b.height)], "opacity": (alpha(owner) * 100.0).round() / 100.0,- "color": color, "size": font.font_size.computed_size().px() as f64, "weight": font.font_weight.value() as f64, "align": align});- stamps(owner, &mut t);- text.push(t);- }- (videos, text)- }}/// Pages' first frames (a scripted page's once reftest-wait is gone) as PNGs on the Blitz page (`raea shots --pagediff --git a/engine/page/src/motion/manifest.rs b/engine/page/src/motion/manifest.rsnew file mode 100644index 00000000..be36a50d--- /dev/null+++ b/engine/page/src/motion/manifest.rs@@ -0,0 +1,122 @@+//! The render manifest's videos and text (render.json, `raea render --manifest`), as the page laid them out.++use super::*;++impl BlitzPage {+ /// The render manifest's videos and text, as laid out (raea check's clipped, safe-area and reading rules read it):+ /// each shown element with a `data-raea-src` (a video: its source, time and box), and each element's own words+ /// (its text children's, inline elements' words going to the nearest element up with a box) with that box, its+ /// opacity, colour, size, weight and alignment as computed. In document order, as raea-runtime-js's page gave them.+ pub fn manifest(&mut self) -> (Vec<serde_json::Value>, Vec<serde_json::Value>) {+ use serde_json::json;+ use style::computed_values::visibility::T as Visibility;+ use style::values::specified::text::TextAlignKeyword;+ let docs = self.app.world().non_send::<Docs>();+ let Some(doc) = docs.0.get(&self.page) else { return (vec![], vec![]) };+ let r = |v: f64| (v * 10.0).round() / 10.0;+ let rect = |n: blitz_dom::NodeId| doc.get_client_bounding_rect(n).filter(|b| b.width > 0.0 && b.height > 0.0);+ // its own opacity times its parents', 0 when it or one of them isn't shown+ let alpha = |n: blitz_dom::NodeId| -> f64 {+ let (mut a, mut at) = (1.0f64, Some(n));+ while let Some(x) = at {+ let Some(node) = doc.get_node(x) else { break };+ if node.is_element() {+ let Some(s) = node.primary_styles() else { return 0.0 };+ if !node.has_boxes() || (x == n && matches!(s.clone_visibility(), Visibility::Hidden | Visibility::Collapse)) {+ return 0.0;+ }+ a *= s.get_effects().opacity as f64;+ }+ at = node.parent;+ }+ a+ };+ // the source stamps (engine/bundle stamp.rs) of the nearest element up from `n` that has them: where the JSX+ // is written ("promo.tsx:12:7"), and the uses of the edit's components it was drawn in, nearest first+ let stamps = |n: blitz_dom::NodeId, entry: &mut serde_json::Value| {+ let mut at = Some(n);+ while let Some(x) = at {+ let Some(node) = doc.get_node(x) else { break };+ if let Some(loc) = node.attr(LocalName::from("data-raea-loc")) {+ entry["loc"] = json!(loc);+ if let Some(uses) = node.attr(LocalName::from("data-raea-use")).filter(|u| !u.is_empty()) {+ entry["use"] = json!(uses.split('|').collect::<Vec<_>>());+ }+ // its place in a list (its .map()'s key), when it has one+ if let Some(idx) = node.attr(LocalName::from("data-raea-idx")) {+ entry["index"] = json!(idx);+ }+ return;+ }+ at = node.parent;+ }+ };+ let (mut videos, mut text) = (Vec::new(), Vec::new());+ let mut owned: Vec<(blitz_dom::NodeId, Vec<String>)> = Vec::new();+ // the whole document: a composition's sequences and screens are pages of their own under the root's+ let mut stack = vec![doc.root_node().id];+ while let Some(n) = stack.pop() {+ let Some(node) = doc.get_node(n) else { continue };+ if node.is_element() && matches!(node.element_data().map(|e| &*e.name.local), Some("style" | "script")) {+ continue;+ }+ stack.extend(node.children.iter().rev().copied());+ if let Some(src) = node.attr(LocalName::from("data-raea-src")) {+ let a = alpha(n);+ if let (Some(b), true) = (rect(n), a > 0.01) {+ let at = node.attr(LocalName::from("data-raea-at")).and_then(|v| v.parse::<f64>().ok()).unwrap_or(0.0);+ let mut v = json!({"src": src, "at": at, "box": [r(b.x), r(b.y), r(b.width), r(b.height)], "opacity": (a * 100.0).round() / 100.0});+ stamps(n, &mut v);+ videos.push(v);+ }+ continue;+ }+ if !node.is_text_node() {+ continue;+ }+ let words = node.text_content();+ let words = words.trim();+ if words.is_empty() {+ continue;+ }+ // an inline element (a <span> around a caption word) has no box of its own: its words belong to the+ // nearest element up that has one+ let mut up = node.parent;+ while let Some(p) = up {+ let inline = doc.get_node(p).and_then(|x| x.primary_styles()).is_some_and(|s| s.clone_display().outside() == style::values::specified::box_::DisplayOutside::Inline);+ if !inline && rect(p).is_some() {+ break;+ }+ up = doc.get_node(p).and_then(|x| x.parent);+ }+ let Some(owner) = up else { continue };+ if node.parent.is_none_or(|p| alpha(p) <= 0.01) {+ continue;+ }+ match owned.iter_mut().find(|(o, _)| *o == owner) {+ Some((_, ws)) => ws.push(words.to_string()),+ None => owned.push((owner, vec![words.to_string()])),+ }+ }+ for (owner, words) in owned {+ let (Some(b), Some(node)) = (rect(owner), doc.get_node(owner)) else { continue };+ let Some(s) = node.primary_styles() else { continue };+ let c = s.clone_color().to_color_space(style::color::ColorSpace::Srgb);+ let [cr, cg, cb] = [c.components.0, c.components.1, c.components.2].map(|v| (v.clamp(0.0, 1.0) * 255.0).round());+ let ca = c.alpha;+ let color = if ca >= 1.0 { format!("rgb({cr}, {cg}, {cb})") } else { format!("rgba({cr}, {cg}, {cb}, {})", (ca * 1000.0).round() / 1000.0) };+ let font = s.get_font();+ let align = match s.clone_text_align() {+ TextAlignKeyword::Center | TextAlignKeyword::MozCenter => "center",+ TextAlignKeyword::Right | TextAlignKeyword::End | TextAlignKeyword::MozRight => "right",+ TextAlignKeyword::Justify => "justify",+ _ => "left",+ };+ let mut t = json!({"text": words.join(" "), "box": [r(b.x), r(b.y), r(b.width), r(b.height)], "opacity": (alpha(owner) * 100.0).round() / 100.0,+ "color": color, "size": font.font_size.computed_size().px() as f64, "weight": font.font_weight.value() as f64, "align": align});+ stamps(owner, &mut t);+ text.push(t);+ }+ (videos, text)+ }+}diff --git a/io/home/src/lib.rs b/io/home/src/lib.rsindex 2f8462dd..a77c388a 100644--- a/io/home/src/lib.rs+++ b/io/home/src/lib.rs@@ -244,3 +244,9 @@ mod offline_tests {let _ = std::fs::remove_file(&file);}}++/// Whether the environment variable `name` is set to exactly "1" (raea's switches: RAEA_SOURCE_STAMPS=1,+/// RAEA_PLAYER_PROBE=1).+pub fn env_on(name: &str) -> bool {+ std::env::var(name).as_deref() == Ok("1")+}diff --git a/runtime/bundle/Cargo.toml b/runtime/bundle/Cargo.tomlindex b63c453e..2367656d 100644--- a/runtime/bundle/Cargo.toml+++ b/runtime/bundle/Cargo.toml@@ -20,6 +20,8 @@ raea-native = { path = "../../engine/native", default-features = false }# an imported long-GOP source's optimized copy, named in the export cache's key (its probe: AVFoundation on Apple, the# soft backend's container reader elsewhere)raea-io-media = { path = "../../io/media", default-features = false, features = ["apple", "soft-audio"] }+# RAEA_HIDE_LAYERS's page CSS (the layer pass's oracle)+raea-sys-layers = { path = "../../systems/layers" }serde_json = "1"regex = "1"# raea-bundle's library (engine/bundle: Rolldown) loaded at run time (fresh.rs inproc), never a Cargo dependency:diff --git a/runtime/bundle/src/fresh.rs b/runtime/bundle/src/fresh.rsindex 4f89d227..617d27d8 100644--- a/runtime/bundle/src/fresh.rs+++ b/runtime/bundle/src/fresh.rs@@ -111,7 +111,7 @@ pub use raea_runtime_bundle_lib as inproc;/// Whether a composition's elements are stamped with their place in the code (engine/bundle stamp.rs): the app's editor/// sets RAEA_SOURCE_STAMPS=1 on the renders it asks for, so its render manifest says which JSX drew whatpub fn stamps() -> bool {- std::env::var("RAEA_SOURCE_STAMPS").as_deref() == Ok("1")+ raea_io_home::env_on("RAEA_SOURCE_STAMPS")}pub fn bundle_fresh(tsx: &Path, out_js: &Path, o: &CompOpts, portable: Option<&Path>) -> R<()> {diff --git a/runtime/bundle/src/lib.rs b/runtime/bundle/src/lib.rsindex db39564b..34e9bd92 100644--- a/runtime/bundle/src/lib.rs+++ b/runtime/bundle/src/lib.rs@@ -65,32 +65,12 @@ pub fn page_css(dir: &Path, w: u32, js: &Path) -> Option<String> {(Some(b), Some(c)) => Some(format!("{b}\n{c}")),(b, c) => b.or(c),};- match (css, hidden_css()) {+ match (css, raea_sys_layers::hidden_css()) {(Some(c), Some(h)) => Some(format!("{c}\n{h}")),(c, h) => c.or(h),}}-/// RAEA_HIDE_LAYERS: the layers keyed (docs/review.feature R2, a key a line or comma) drawn hidden, each element with-/// its stamps and all inside it, as the layer pass's oracle needs (bench/layers). A 3D part's: runtime/scene.-pub fn hidden_css() -> Option<String> {- let keys = std::env::var("RAEA_HIDE_LAYERS").ok()?;- let rules: Vec<String> = keys.split([',', '\n']).filter(|k| !k.trim().is_empty()).map(|k| layer_selector(k.trim())).collect();- (!rules.is_empty()).then(|| format!("{} {{ visibility: hidden !important; }}", rules.join(", ")))-}--/// The CSS selector of the element a layer key names, and of everything inside it: "loc[#index][|use|use…]" as its-/// data-raea-loc, data-raea-idx and data-raea-use (engine/bundle stamp.rs)-pub fn layer_selector(key: &str) -> String {- let (head, uses) = key.split_once('|').map_or((key, None), |(h, u)| (h, Some(u)));- let col = head.rfind(':').unwrap_or(0);- let (loc, idx) = head[col..].find('#').map_or((head, None), |i| (&head[..col + i], Some(&head[col + i + 1..])));- let q = |v: &str| serde_json::to_string(v).unwrap_or_default();- let mut sel = format!("[data-raea-loc={}]", q(loc));- sel.push_str(&idx.map_or_else(|| ":not([data-raea-idx])".to_string(), |i| format!("[data-raea-idx={}]", q(i))));- sel.push_str(&uses.map_or_else(|| ":not([data-raea-use])".to_string(), |u| format!("[data-raea-use={}]", q(u))));- format!("{sel}, {sel} *")-}/// A `\u` escape in a JSX attribute's plain string (`unit="\u00a0pts"`) is no escape there: the page shows the six/// characters. Said once per bundle, with the fix (braces: `unit={"\u00a0pts"}`), for the edit's .tsx files.@@ -258,12 +238,3 @@ pub fn bundle_composition(tsx: &Path, out_js: &Path, o: &CompOpts, portable: OptOk(())}-#[cfg(test)]-mod layer_tests {- #[test]- fn a_layer_key_selects_its_element_alone() {- assert_eq!(super::layer_selector("a.tsx:3:5"), r#"[data-raea-loc="a.tsx:3:5"]:not([data-raea-idx]):not([data-raea-use]), [data-raea-loc="a.tsx:3:5"]:not([data-raea-idx]):not([data-raea-use]) *"#);- let s = super::layer_selector("card.tsx:2:10#2|comp.tsx:6:27#2|x.tsx:1:1");- assert!(s.starts_with(r#"[data-raea-loc="card.tsx:2:10"][data-raea-idx="2"][data-raea-use="comp.tsx:6:27#2|x.tsx:1:1"]"#), "{s}");- }-}diff --git a/runtime/scene/src/lib.rs b/runtime/scene/src/lib.rsindex c3c04a4e..10f6e45b 100644--- a/runtime/scene/src/lib.rs+++ b/runtime/scene/src/lib.rs@@ -185,9 +185,7 @@ fn name_column(row: &mut BTreeMap<String, V>, props: &Map<String, Value>) {fn bevy_parts(n: &Node3, it: &mut Item) {let mut comps: Vec<Value> = n.kids.iter().filter(|k| &*k.kind == "BevyComponent").map(|k| Value::Object((*k.props).clone())).collect();// its source stamp as its layer key (docs/review.feature R2a), a component on the part, not a column its kind reads- let s = |k: &str| n.props.get(k).and_then(Value::as_str);- let idx = n.props.get("data-raea-idx").map(|v| v.as_str().map_or_else(|| v.to_string(), str::to_string));- if let Some(key) = raea_sys_frame::layer::key_of(s("data-raea-loc"), idx.as_deref(), s("data-raea-use")) {+ if let Some(key) = raea_sys_frame::layer::key_from_props(&n.props) {// RAEA_HIDE_LAYERS names it: drawn hidden, for the layer pass's oracle (bench/layers; a page element's: page_css)if std::env::var("RAEA_HIDE_LAYERS").is_ok_and(|h| h.split([',', '\n']).any(|k| k.trim() == key)) {comps.push(serde_json::json!({ "type": "bevy_camera::visibility::Visibility", "value": "Hidden" }));diff --git a/systems/frame/src/layer.rs b/systems/frame/src/layer.rsindex f953d0b4..70cdb68d 100644--- a/systems/frame/src/layer.rs+++ b/systems/frame/src/layer.rs@@ -10,7 +10,7 @@ use bevy::prelude::*;pub struct LayerKey(pub String);/// The key a stamped element or part's props give it (raea-sys-layers owns it: the page's half reads it too).-pub use raea_sys_layers::key_of;+pub use raea_sys_layers::{key_from_props, key_of};/// With `raea render --layers`, frame `f`'s 3D recorded as layer indices (raea-sys-layers, docs/review.feature R2b):diff --git a/systems/layers/src/hide.rs b/systems/layers/src/hide.rsnew file mode 100644index 00000000..c3965985--- /dev/null+++ b/systems/layers/src/hide.rs@@ -0,0 +1,23 @@+//! Layers hidden by key (RAEA_HIDE_LAYERS), as the layer pass's oracle needs them (bench/layers/oracle.sh): a page+//! element as CSS (this), a 3D part as its Visibility (runtime/scene).++use crate::Layer;++/// RAEA_HIDE_LAYERS: the layers keyed (a key a line or comma) drawn hidden, each element with its stamps and all+/// inside it, as page CSS. None when it names none.+pub fn hidden_css() -> Option<String> {+ let keys = std::env::var("RAEA_HIDE_LAYERS").ok()?;+ let rules: Vec<String> = keys.split([',', '\n']).filter(|k| !k.trim().is_empty()).map(|k| layer_selector(k.trim())).collect();+ (!rules.is_empty()).then(|| format!("{} {{ visibility: hidden !important; }}", rules.join(", ")))+}++/// The CSS selector of the element a layer key names, and of everything inside it: "loc[#index][|use|use…]" as its+/// data-raea-loc, data-raea-idx and data-raea-use (engine/bundle stamp.rs)+pub fn layer_selector(key: &str) -> String {+ let l = Layer::of(key.to_string(), "element", String::new(), None, None);+ let q = |v: &str| serde_json::to_string(v).unwrap_or_default();+ let mut sel = format!("[data-raea-loc={}]", q(&l.loc));+ sel.push_str(&l.index.map_or_else(|| ":not([data-raea-idx])".to_string(), |i| format!("[data-raea-idx={}]", q(&i))));+ sel.push_str(&Some(l.uses.join("|")).filter(|u| !u.is_empty()).map_or_else(|| ":not([data-raea-use])".to_string(), |u| format!("[data-raea-use={}]", q(&u))));+ format!("{sel}, {sel} *")+}diff --git a/systems/layers/src/lib.rs b/systems/layers/src/lib.rsindex ba757cfb..f0ca2026 100644--- a/systems/layers/src/lib.rs+++ b/systems/layers/src/lib.rs@@ -5,6 +5,7 @@//! 4y+2)); `Recorder` keeps them with the table of layers and writes NAME.layers (file.rs).mod file;+mod hide;mod names;mod raster;#[cfg(feature = "page")]@@ -13,6 +14,7 @@ mod page;mod scene;pub use file::Recorder;+pub use hide::{hidden_css, layer_selector};pub use raster::{Tri, raster};#[cfg(feature = "page")]pub use page::page_ids;@@ -37,6 +39,13 @@ pub fn key_of(loc: Option<&str>, idx: Option<&str>, uses: Option<&str>) -> OptioSome(k)}+/// The key of a stamped part from its props (data-raea-loc, data-raea-idx, which a numeric list key leaves a number,+/// and data-raea-use), as key_of gives it. None for an unstamped one.+pub fn key_from_props(props: &serde_json::Map<String, serde_json::Value>) -> Option<String> {+ let text = |k: &str| props.get(k).map(|v| v.as_str().map_or_else(|| v.to_string(), str::to_string));+ key_of(text("data-raea-loc").as_deref(), text("data-raea-idx").as_deref(), text("data-raea-use").as_deref())+}+/// One layer of the table: what NAME.layers' header lists for it.#[derive(Clone, Debug, PartialEq)]pub struct Layer {diff --git a/systems/layers/src/scene.rs b/systems/layers/src/scene.rsindex 27bf01a3..30aa39f5 100644--- a/systems/layers/src/scene.rs+++ b/systems/layers/src/scene.rs@@ -125,6 +125,12 @@ impl PaintScene for IdScene<'_> {}}- /// a shadow is not its element's: the layer under it shows there- fn draw_box_shadow(&mut self, _transform: Affine, _rect: Rect, _brush: Color, _radius: f64, _std_dev: f64) {}+ /// a shadow is its element's (hiding the element hides it): drawn out to where its blur still shows, about 1.5+ /// deviations past its box+ fn draw_box_shadow(&mut self, transform: Affine, rect: Rect, brush: Color, radius: f64, std_dev: f64) {+ if self.brush(PaintRef::Solid(brush), transform) {+ let grow = 1.5 * std_dev;+ self.ctx.fill_path(&vello_cpu::kurbo::RoundedRect::from_rect(rect.inflate(grow, grow), radius + grow).into_path(TOLERANCE));+ }+ }}diff --git a/systems/layers/src/tests.rs b/systems/layers/src/tests.rsindex 52f85daa..380e9571 100644--- a/systems/layers/src/tests.rs+++ b/systems/layers/src/tests.rs@@ -87,3 +87,10 @@ fn a_uses_root_is_named_after_its_component() {assert_eq!(head["layers"][2]["name"], "span", "inside the use, not its root");let _ = std::fs::remove_dir_all(dir);}++#[test]+fn a_layer_key_selects_its_element_alone() {+ assert_eq!(layer_selector("a.tsx:3:5"), r#"[data-raea-loc="a.tsx:3:5"]:not([data-raea-idx]):not([data-raea-use]), [data-raea-loc="a.tsx:3:5"]:not([data-raea-idx]):not([data-raea-use]) *"#);+ let s = layer_selector("card.tsx:2:10#2|comp.tsx:6:27#2|x.tsx:1:1");+ assert!(s.starts_with(r#"[data-raea-loc="card.tsx:2:10"][data-raea-idx="2"][data-raea-use="comp.tsx:6:27#2|x.tsx:1:1"]"#), "{s}");+}diff --git a/tools/layers.toml b/tools/layers.tomlindex df93ed20..bf41b71a 100644--- a/tools/layers.toml+++ b/tools/layers.toml@@ -101,6 +101,7 @@ raea-sys-look = "systems"raea-sys-compose = "systems"raea-sys-material = "systems"raea-sys-mesh = "systems"+raea-sys-layers = "systems"raea-sys-framepass = "systems"raea-sys-compute = "systems"raea-sys-phase = "systems"@@ -176,6 +177,8 @@ seetool = "tools"[facility]# the frame's rows every pass reads (FrameRows, the edit, the clock, row helpers)raea-sys-frame = true+# the layer pass's keys, table, raster and NAME.layers (raea-sys-frame records the 3D through it)+raea-sys-layers = true# a row's standard material and its maps (meshseq builds its mesh's on it)raea-sys-material = true# a row's mesh from JSON, Bevy's primitives by name (materials and reflected Mesh handles build on it)