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.

Layer keys (docs/review.feature R2a, work in progress, parked with the source stamps): a .map()'s key in the stamps (data-raea-idx, and loc#key in a use chain); raea's 3D parts (Mesh3d, Model, Entity…) stamped and given a LayerKey component (raea_sys_frame::layer) from it in runtime/scene; the work folder's SDK imports (../motion/x) read as raea's, not the edit's own; only components that read their children's types keep them unwrapped; RAEA_HIDE_LAYERS hides a layer by key (page CSS from its stamps, a 3D part's Visibility) for the layer pass's oracle. Not for landing before the layer pass.

shinyobjectz09a935abd0b7
diff --git a/Cargo.lock b/Cargo.lock
index 82f40edc..5dec7438 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -14967,6 +14967,7 @@ dependencies = [
"raea-core-scene",
"raea-runtime-look",
"raea-runtime-scene2d",
+ "raea-sys-frame",
"raea-sys-procmat",
"raea-sys-wear",
"serde_json",
diff --git a/engine/bundle/src/stamp.rs b/engine/bundle/src/stamp.rs
index 4bc9ab26..264de126 100644
--- a/engine/bundle/src/stamp.rs
+++ b/engine/bundle/src/stamp.rs
@@ -28,6 +28,21 @@ const HTML: &[&str] = &[
"div", "span", "p", "h1", "h2", "h3", "h4", "h5", "h6", "section", "article", "header", "footer", "main", "aside", "nav", "figure", "figcaption", "blockquote", "pre", "code", "strong", "em", "b", "i", "u", "s", "small", "mark", "sub", "sup", "label", "ul", "ol", "li", "dl", "dt", "dd", "img", "video", "audio", "picture", "a", "button", "table", "tr", "td", "th", "svg", "canvas", "br", "hr",
];
+/// raea's modules whose components draw 3D parts (a Mesh3d, a Model, a Sprite): their uses are stamped as an HTML
+/// element is, and the scene gives the part a LayerKey component from it (runtime/scene bevy_parts), so a 3D part is
+/// a layer as an element is (docs/review.feature R2a). Never a prop the part's kind reads.
+const PARTS3D: &[&str] = &["raea/3d", "raea/mesh", "raea/sprite"];
+
+/// The parts among them, by the name they're exported as: what draws a thing on its own. Never a shape or a material
+/// inside one (a Mesh3d reads its <Cuboid> child's props, and an extra prop there made it no shape at all).
+const PART_NAMES: &[&str] = &["Mesh3d", "Model", "SceneRoot", "Entity", "Sprite", "Text3D", "Text2d", "ImagePlane", "ShaderMesh", "Plate", "Decal", "Splat", "Grass", "Mesh2d"];
+
+/// Package components that read their children's types, whose children are left as written (a wrapper there would
+/// hide a <Series.Sequence> from its <Series>, a <Cuboid> from its <Mesh3d>): every component of raea's 3D, material,
+/// light and camera modules, and these by name
+const READERS_MODULES: &[&str] = &["raea/3d", "raea/mesh", "raea/sprite", "raea/pbr", "raea/light", "raea/camera"];
+const READERS: &[&str] = &["Series", "TransitionSeries"];
+
/// The helper module stamped files import: the context and its two readers.
pub const HELPER: &str = r#"// raea's source stamps (engine/bundle stamp.rs): the use sites of the edit's components, nearest first
import { createContext, useContext } from "react";
@@ -42,9 +57,10 @@ const read = (): string => {
};
export const __RaeaAt = At.Provider;
export const __raeaUse = (): string | undefined => read() || undefined;
-export const __raeaChain = (loc: string): string => {
+export const __raeaChain = (loc: string, key?: unknown): string => {
+ const at = key === undefined || key === null ? loc : `${loc}#${String(key)}`;
const up = read();
- return up ? `${loc}|${up}` : loc;
+ return up ? `${at}|${up}` : at;
};
"#;
@@ -59,14 +75,29 @@ pub fn stamp(source: &str, rel: &str, jsx: bool, helper: &str) -> Option<String>
return None;
}
let mut imports = HashMap::new();
+ let mut parts3d = std::collections::HashSet::new();
+ let mut readers = std::collections::HashSet::new();
for s in &parsed.program.body {
let Statement::ImportDeclaration(d) = s else { continue };
- let local = d.source.value.starts_with('.');
+ let (local, module) = module_of(rel, d.source.value.as_str());
+ let is3d = PARTS3D.contains(&module.as_str());
+ let reads = is3d || READERS_MODULES.contains(&module.as_str());
for sp in d.specifiers.iter().flatten() {
imports.insert(sp.local().name.to_string(), local);
+ let name = sp.local().name.to_string();
+ if !local && (reads || READERS.contains(&name.as_str())) {
+ readers.insert(name);
+ }
+ let exported = match sp {
+ ImportDeclarationSpecifier::ImportSpecifier(x) => x.imported.name().to_string(),
+ _ => String::new(),
+ };
+ if is3d && PART_NAMES.contains(&exported.as_str()) {
+ parts3d.insert(sp.local().name.to_string());
+ }
}
}
- let mut v = Stamper { src: source, rel, imports, parents: Vec::new(), edits: Vec::new(), lines: line_starts(source) };
+ let mut v = Stamper { src: source, rel, imports, parts3d, readers, parents: Vec::new(), edits: Vec::new(), lines: line_starts(source) };
v.visit_program(&parsed.program);
if v.edits.is_empty() {
return None;
@@ -102,6 +133,10 @@ struct Stamper<'s> {
rel: &'s str,
/// each imported name: true when it's from a relative path (the edit's own)
imports: HashMap<String, bool>,
+ /// the names imported from PARTS3D's modules
+ parts3d: std::collections::HashSet<String>,
+ /// the package components that read their children's types (READERS)
+ readers: std::collections::HashSet<String>,
parents: Vec<Kind>,
/// (at, end, text): `src[at..end]` replaced by `text`
edits: Vec<(usize, usize, String)>,
@@ -117,13 +152,31 @@ impl Stamper<'_> {
}
}
+impl Stamper<'_> {
+ /// The source of an element's `key` value, as an expression: `{i}` gives `i`, `"a"` gives `"a"`
+ fn key_expr(&self, open: &JSXOpeningElement) -> Option<String> {
+ open.attributes.iter().find_map(|a| match a {
+ JSXAttributeItem::Attribute(x) if matches!(&x.name, JSXAttributeName::Identifier(n) if n.name == "key") => match x.value.as_ref()? {
+ JSXAttributeValue::ExpressionContainer(c) => c.expression.as_expression().map(|e| self.src[e.span().start as usize..e.span().end as usize].to_string()),
+ JSXAttributeValue::StringLiteral(l) => Some(json(l.value.as_str())),
+ _ => None,
+ },
+ _ => None,
+ })
+ }
+}
+
impl<'a> Visit<'a> for Stamper<'_> {
fn visit_jsx_element(&mut self, it: &JSXElement<'a>) {
let open = &it.opening_element;
let mut kind = Kind::Open;
match &open.name {
JSXElementName::Identifier(id) if HTML.contains(&id.name.as_str()) => {
- let text = format!(" data-raea-loc={} data-raea-use={{__raeaUse()}}", json(&self.loc(it.span.start as usize)));
+ let mut text = format!(" data-raea-loc={} data-raea-use={{__raeaUse()}}", json(&self.loc(it.span.start as usize)));
+ // its place in a list (a .map()'s key), so five cards drawn by one line have five keys
+ if let Some(k) = self.key_expr(open) {
+ text.push_str(&format!(" data-raea-idx={{{k}}}"));
+ }
let at = open.name.span().end as usize;
self.edits.push((at, at, text));
}
@@ -133,7 +186,19 @@ impl<'a> Visit<'a> for Stamper<'_> {
// the edit's own: defined here (not imported) or imported from a relative path
let own = self.imports.get(name).copied().unwrap_or(true);
if !own {
- kind = Kind::Package;
+ // a package component that reads its children's types (a Series, a 3D part's shape and material)
+ // gets them as written; any other (an AbsoluteFill, a Sequence) is a plain element's parent
+ if self.readers.contains(name) {
+ kind = Kind::Package;
+ }
+ if self.parts3d.contains(name) {
+ let mut text = format!(" data-raea-loc={} data-raea-use={{__raeaUse()}}", json(&self.loc(it.span.start as usize)));
+ if let Some(k) = self.key_expr(open) {
+ text.push_str(&format!(" data-raea-idx={{{k}}}"));
+ }
+ let at = r.span.end as usize;
+ self.edits.push((at, at, text));
+ }
} else if self.parents.last() != Some(&Kind::Package) {
let (start, end) = (it.span.start as usize, it.span.end as usize);
// a key belongs on what's in the list: the wrapper
@@ -141,7 +206,8 @@ impl<'a> Visit<'a> for Stamper<'_> {
JSXAttributeItem::Attribute(x) if matches!(&x.name, JSXAttributeName::Identifier(n) if n.name == "key") => Some(x.span),
_ => None,
});
- let mut wrap = format!("<__RaeaAt value={{__raeaChain({})}}", json(&self.loc(start)));
+ let idx = self.key_expr(open).map(|k| format!(", {k}")).unwrap_or_default();
+ let mut wrap = format!("<__RaeaAt value={{__raeaChain({}{idx})}}", json(&self.loc(start)));
if let Some(k) = key {
wrap.push(' ');
wrap.push_str(&self.src[k.start as usize..k.end as usize]);
@@ -167,6 +233,36 @@ impl<'a> Visit<'a> for Stamper<'_> {
}
}
+/// Whether an import from the file at `rel` (its path under src/) is the edit's own, and the module it names as an
+/// edit would write it. The work folder's copies import raea's SDK at motion/ beside src/ ("raea/mesh" is
+/// "../motion/mesh" there: fresh.rs rewrite_into), so a relative path is the edit's own only while it stays in src/,
+/// and one into motion/ is raea's ("raea/mesh"); a bare one is a package's as it is.
+fn module_of(rel: &str, spec: &str) -> (bool, String) {
+ if !spec.starts_with('.') {
+ return (false, spec.to_string());
+ }
+ let mut at: Vec<&str> = rel.split('/').collect();
+ at.pop();
+ let mut out = false;
+ for part in spec.split('/') {
+ match part {
+ "." | "" => {}
+ ".." if at.pop().is_none() => out = true,
+ ".." => {}
+ p if out => at.push(p),
+ p => at.push(p),
+ }
+ }
+ if !out {
+ return (true, spec.to_string());
+ }
+ match at.split_first() {
+ Some((&"motion", rest)) if rest.is_empty() || rest == ["index"] => (false, "raea".into()),
+ Some((&"motion", rest)) => (false, format!("raea/{}", rest.join("/"))),
+ _ => (false, spec.to_string()),
+ }
+}
+
fn line_starts(s: &str) -> Vec<usize> {
std::iter::once(0).chain(s.match_indices('\n').map(|(i, _)| i + 1)).collect()
}
@@ -205,7 +301,47 @@ mod tests {
fn own_components_are_wrapped_with_their_use_and_keep_the_key() {
let src = "import { Card } from \"./card\";\nimport { Series } from \"raea\";\nconst X = () => <>{[1, 2].map((i) => <Card key={i} n={i} />)}</>;\n";
let out = stamp(src, "p.tsx", false, H).unwrap();
- assert!(out.contains(r#"<__RaeaAt value={__raeaChain("p.tsx:3:38")} key={i}><Card n={i} /></__RaeaAt>"#), "{out}");
+ assert!(out.contains(r#"<__RaeaAt value={__raeaChain("p.tsx:3:38", i)} key={i}><Card n={i} /></__RaeaAt>"#), "{out}");
+ }
+
+ #[test]
+ fn an_html_element_in_a_list_carries_its_key() {
+ let src = "const X = () => <ul>{[\"a\", \"b\"].map((t) => <li key={t}>{t}</li>)}<li key=\"z\" /></ul>;\n";
+ let out = stamp(src, "l.tsx", false, H).unwrap();
+ assert!(out.contains(r#"<li data-raea-loc="l.tsx:1:44" data-raea-use={__raeaUse()} data-raea-idx={t} key={t}>"#), "{out}");
+ assert!(out.contains(r#"data-raea-idx={"z"} key="z""#), "{out}");
+ }
+
+ #[test]
+ fn a_3d_part_from_raeas_3d_modules_is_stamped_and_other_packages_are_not() {
+ let src = "import { Mesh3d, Cuboid } from \"raea/mesh\";\nimport { Model } from \"raea/3d\";\nimport { Series } from \"raea\";\nconst X = () => <Series>{[0, 1].map((i) => <Mesh3d key={i} />)}<Model src=\"a.glb\" /></Series>;\n";
+ let out = stamp(src, "s.tsx", false, H).unwrap();
+ assert!(out.contains(r#"<Mesh3d data-raea-loc="s.tsx:4:44" data-raea-use={__raeaUse()} data-raea-idx={i} key={i} />"#), "{out}");
+ assert!(out.contains(r#"<Model data-raea-loc="s.tsx:4:64" data-raea-use={__raeaUse()} src="a.glb" />"#), "{out}");
+ assert!(out.contains("<Series>{"), "{out}");
+ // a shape inside a part is the part's, left as written
+ let out = stamp("import { Mesh3d, Cuboid } from \"raea/mesh\";\nconst Y = () => <Mesh3d><Cuboid /></Mesh3d>;\n", "s.tsx", false, H).unwrap();
+ assert!(out.contains("<Cuboid />"), "{out}");
+ }
+
+ #[test]
+ fn the_work_folders_sdk_imports_are_raeas_not_the_edits() {
+ assert_eq!(module_of("comp.tsx", "./card"), (true, "./card".into()));
+ assert_eq!(module_of("lib/x.tsx", "../card"), (true, "../card".into()));
+ assert_eq!(module_of("comp.tsx", "../motion/mesh"), (false, "raea/mesh".into()));
+ assert_eq!(module_of("lib/x.tsx", "../../motion"), (false, "raea".into()));
+ assert_eq!(module_of("comp.tsx", "raea/3d"), (false, "raea/3d".into()));
+ // as the work folder has it: the SDK's parts stamped, its shapes and own wrappers not
+ let src = "import { Cuboid, Mesh3d } from \"../motion/mesh\";\nimport { Camera3d } from \"../motion/camera\";\nconst X = () => <><Camera3d /><Mesh3d><Cuboid /></Mesh3d></>;\n";
+ let out = stamp(src, "comp.tsx", false, H).unwrap();
+ assert!(out.contains("<><Camera3d /><Mesh3d data-raea-loc=\"comp.tsx:3:31\" data-raea-use={__raeaUse()}><Cuboid /></Mesh3d></>"), "{out}");
+ }
+
+ #[test]
+ fn a_plain_package_component_is_a_parent_like_an_element() {
+ let src = "import { AbsoluteFill } from \"raea\";\nimport { Card } from \"./card\";\nconst X = () => <AbsoluteFill><Card /></AbsoluteFill>;\n";
+ let out = stamp(src, "p.tsx", false, H).unwrap();
+ assert!(out.contains(r#"<AbsoluteFill><__RaeaAt value={__raeaChain("p.tsx:3:31")}><Card /></__RaeaAt></AbsoluteFill>"#), "{out}");
}
#[test]
diff --git a/engine/page/src/motion.rs b/engine/page/src/motion.rs
index 7bd151a0..a8bbb45a 100644
--- a/engine/page/src/motion.rs
+++ b/engine/page/src/motion.rs
@@ -395,6 +395,10 @@ impl BlitzPage {
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;
diff --git a/runtime/bundle/src/lib.rs b/runtime/bundle/src/lib.rs
index 0235784f..db39564b 100644
--- a/runtime/bundle/src/lib.rs
+++ b/runtime/bundle/src/lib.rs
@@ -61,12 +61,37 @@ pub fn bundle_css(js: &str) -> Option<String> {
pub fn page_css(dir: &Path, w: u32, js: &Path) -> Option<String> {
// its url()s as files from the edit's folder (urls.rs), where the CSS files it imports are found
let bundled = std::fs::read_to_string(js).ok().and_then(|t| bundle_css(&t)).map(|c| css_file_urls(&c, dir, dir, |_| ()));
- match (brand_css(dir, w), bundled) {
+ let css = match (brand_css(dir, w), bundled) {
(Some(b), Some(c)) => Some(format!("{b}\n{c}")),
(b, c) => b.or(c),
+ };
+ match (css, 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.
pub fn jsx_escape_lint(dir: &Path) {
@@ -232,3 +257,13 @@ pub fn bundle_composition(tsx: &Path, out_js: &Path, o: &CompOpts, portable: Opt
}
Ok(())
}
+
+#[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/plugins/src/lib.rs b/runtime/plugins/src/lib.rs
index cc197c6c..a236c3fb 100644
--- a/runtime/plugins/src/lib.rs
+++ b/runtime/plugins/src/lib.rs
@@ -118,6 +118,8 @@ pub fn install(app: &mut App, fps: f64) {
// them without registering them for reflection; the gamepad's ButtonInput it registers itself)
app.register_type::<ButtonInput<KeyCode>>();
app.register_type::<ButtonInput<MouseButton>>();
+ // a drawn part's layer key, a component row from its source stamp (docs/review.feature R2a)
+ app.register_type::<raea_sys_frame::layer::LayerKey>();
// a Range field (a Viewport's depth) is reflected opaque without serde's data: given it, it reads as {start, end}
app.register_type_data::<core::ops::Range<f32>, ReflectDeserialize>();
app.register_type_data::<core::ops::Range<f32>, ReflectSerialize>();
diff --git a/runtime/scene/Cargo.toml b/runtime/scene/Cargo.toml
index 51bf0c2d..2de06a5a 100644
--- a/runtime/scene/Cargo.toml
+++ b/runtime/scene/Cargo.toml
@@ -19,3 +19,5 @@ raea-sys-wear = { path = "../../systems/wear" }
raea-sys-procmat = { path = "../../systems/procmat" }
# a review's fixed camera (RAEA_CAMERA) in place of the scene's own
raea-core-review = { path = "../../core/review" }
+# a part's layer key from its source stamp (docs/review.feature R2a)
+raea-sys-frame = { path = "../../systems/frame" }
diff --git a/runtime/scene/src/lib.rs b/runtime/scene/src/lib.rs
index 517bd31b..c3c04a4e 100644
--- a/runtime/scene/src/lib.rs
+++ b/runtime/scene/src/lib.rs
@@ -183,7 +183,17 @@ fn name_column(row: &mut BTreeMap<String, V>, props: &Map<String, Value>) {
/// The <BevyComponent> children of a part (a Mesh, a Model, a light, the camera) onto its item as `components`: Bevy's
/// own reflected components, or a compiled-in plugin's, applied by raea-render through the TypeRegistry (plugins.rs).
fn bevy_parts(n: &Node3, it: &mut Item) {
- let comps: Vec<Value> = n.kids.iter().filter(|k| &*k.kind == "BevyComponent").map(|k| Value::Object((*k.props).clone())).collect();
+ 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")) {
+ // 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" }));
+ }
+ comps.push(serde_json::json!({ "type": "raea_sys_frame::layer::LayerKey", "value": key }));
+ }
if !comps.is_empty() {
std::sync::Arc::make_mut(&mut it.props).insert("components".into(), Value::Array(comps));
}
diff --git a/systems/frame/src/layer.rs b/systems/frame/src/layer.rs
new file mode 100644
index 00000000..2039eb79
--- /dev/null
+++ b/systems/frame/src/layer.rs
@@ -0,0 +1,38 @@
+//! A drawn thing's layer key (docs/review.feature R2a): where its JSX is written, its place in a list, and the uses of
+//! the edit's components it was drawn in, as engine/bundle's source stamps give them. A 3D part carries it as this
+//! component (runtime/scene bevy_parts makes it a component row of the part), never as a column its kind reads.
+
+use bevy::prelude::*;
+
+/// "file:line:col[#index]|use|use…": the part's stamp, then its use chain, nearest first
+#[derive(Component, Reflect, Default, Clone, Debug, PartialEq, Eq)]
+#[reflect(Component, Default)]
+pub struct LayerKey(pub String);
+
+/// The key a stamped element or part's props give it: `data-raea-loc`, `#data-raea-idx` when it has one, then
+/// `|data-raea-use` when it was drawn inside the edit's components. None for an unstamped one.
+pub fn key_of(loc: Option<&str>, idx: Option<&str>, uses: Option<&str>) -> Option<String> {
+ let loc = loc.filter(|l| !l.is_empty())?;
+ let mut k = loc.to_string();
+ if let Some(i) = idx.filter(|i| !i.is_empty()) {
+ k.push('#');
+ k.push_str(i);
+ }
+ if let Some(u) = uses.filter(|u| !u.is_empty()) {
+ k.push('|');
+ k.push_str(u);
+ }
+ Some(k)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn a_key_is_the_stamp_its_place_and_its_uses() {
+ assert_eq!(key_of(Some("a.tsx:3:5"), None, None).as_deref(), Some("a.tsx:3:5"));
+ assert_eq!(key_of(Some("card.tsx:2:10"), Some("2"), Some("comp.tsx:6:27#2")).as_deref(), Some("card.tsx:2:10#2|comp.tsx:6:27#2"));
+ assert_eq!(key_of(None, Some("2"), Some("x")), None);
+ }
+}
diff --git a/systems/frame/src/lib.rs b/systems/frame/src/lib.rs
index 4795f592..f1f5b5f2 100644
--- a/systems/frame/src/lib.rs
+++ b/systems/frame/src/lib.rs
@@ -12,6 +12,8 @@ use raea_core_program::ir::{Program, V};
pub mod bevy_api;
/// a camera row's order, clear and viewport among the cameras on its target
pub mod camera;
+/// layer keys (docs/review.feature R2)
+pub mod layer;
/// pipelined updates: the render world drawing the last frame while the main world runs this one
pub mod pipe;
// the edit's rows as entities, each column a component of its own, found by kind and id