Windows: canonicalize goes through dunce and the home folder through user_home in the stage, the bundler, export and live play

Four of the five crates 57f3ef8db3 ("all but five crates") left out while they held other uncommitted work: engine/page/stage's ~/ path for a shown file reads raea_io_home::user_home() (HOME, then USERPROFILE), and runtime/bundle's cache and freshness checks, runtime/export's render, review and scene, and runtime/live's open use dunce::canonicalize, which gives C:\... on Windows and is std's own call on the Mac and Linux. engine/render, the fifth, comes with tools/windows-paths.sh on windows-paths-render.

That other work is parked as found on realtime-wip (stacked above this, never landed) and render-3d-first-wip.
This commit is contained in:
shinyobjectz committed 2026-11-17 11:07:55 -08:00
1 parent 5cf62e80ee
commit e388258bff
12 files changed
+22 -16

No files matched your search

Generated
+3
View File
@@ -14803,6 +14803,7 @@ dependencies = [
"bevy",
"blitz-dom",
"raea-gpu-device",
"raea-io-home",
"raea-runtime-bake",
"raea-runtime-dom",
"raea-runtime-js",
@@ -15196,6 +15197,7 @@ name = "raea-runtime-export"
version = "0.1.0"
dependencies = [
"bevy",
"dunce",
"image",
"raea-core-facts",
"raea-core-program",
@@ -15294,6 +15296,7 @@ version = "0.1.0"
dependencies = [
"bevy",
"cpal 0.15.3",
"dunce",
"image",
"raea-core-program",
"raea-gpu-device",
+1
View File
@@ -8,6 +8,7 @@ description = "The live stage in a raea page: a game item's composition played l
[dependencies]
bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "default_font", "multi_threaded", "3d_bevy_render", "ui_bevy_render", "png", "tonemapping_luts", "ktx2", "zstd_rust", "bevy_picking", "ui_picking", "bevy_ui_widgets", "bevy_input_focus", "jpeg", "bevy_remote", "tga", "qoi", "tiff", "pnm", "ff", "dds", "exr", "hdr", "webp", "gif", "bmp", "ico"] }
raea-io-home = { path = "../../../io/home" }
raea-runtime-js = { path = "../../../runtime/js" }
raea-runtime-dom = { path = "../../../runtime/dom" }
raea-sys-page = { path = "../../../systems/page" }
+1 -1
View File
@@ -35,7 +35,7 @@ pub(super) fn calls(mut calls: ResMut<HostCalls>) {
return answer.err("the stage needs the shared device (RAEA_SHARED_DEVICE=0 turned it off)");
}
// a feed item names its game as the app's host does (host/make.ts resolve): ~/ is the home
let src = a.get("src").and_then(Value::as_str).map(|s| match (s.strip_prefix("~/"), std::env::var_os("HOME")) {
let src = a.get("src").and_then(Value::as_str).map(|s| match (s.strip_prefix("~/"), raea_io_home::user_home()) {
(Some(rest), Some(home)) => PathBuf::from(home).join(rest),
_ => PathBuf::from(s),
});
+5 -5
View File
@@ -32,7 +32,7 @@ pub fn export_cache(tsx: &Path, js: &Path, out: &Path, args: &[String]) -> Optio
eat(&bundle);
eat(ext.as_bytes());
// this build (its binary's modification time and size): another engine paints other bytes
if let Some(m) = std::env::current_exe().ok().and_then(|e| std::fs::canonicalize(e).ok()).and_then(|e| e.metadata().ok()) {
if let Some(m) = std::env::current_exe().ok().and_then(|e| dunce::canonicalize(e).ok()).and_then(|e| e.metadata().ok()) {
let t = m.modified().ok().and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok()).map(|d| d.as_nanos()).unwrap_or(0);
eat(&t.to_le_bytes());
eat(&m.len().to_le_bytes());
@@ -48,7 +48,7 @@ pub fn export_cache(tsx: &Path, js: &Path, out: &Path, args: &[String]) -> Optio
continue;
}
// a path by where it really is (/var and /private/var are one folder)
match std::fs::canonicalize(a) {
match dunce::canonicalize(a) {
Ok(p) => eat(p.as_os_str().as_encoded_bytes()),
Err(_) => eat(a.as_bytes()),
}
@@ -79,7 +79,7 @@ pub fn export_cache(tsx: &Path, js: &Path, out: &Path, args: &[String]) -> Optio
}
}
}
let out_abs = std::fs::canonicalize(out).unwrap_or_else(|_| out.to_path_buf());
let out_abs = dunce::canonicalize(out).unwrap_or_else(|_| out.to_path_buf());
walk(tsx.parent()?, 0, &out_abs, &mut files);
// exports this cache wrote (an earlier render's OUT.mp4 beside the edit) are outputs, not inputs, unless the
// composition plays them: a cut laid from its shots' renders (anything/cut/intro.tsx over intro/renders/*.mp4)
@@ -92,14 +92,14 @@ pub fn export_cache(tsx: &Path, js: &Path, out: &Path, args: &[String]) -> Optio
// (a file is one of them only if its name is one of theirs, or it is a link to one: only those are resolved)
let names: std::collections::HashSet<&std::ffi::OsStr> = made.iter().filter_map(|m| m.file_name()).collect();
let may_be_made = |p: &Path| p.file_name().is_some_and(|n| names.contains(n)) || p.symlink_metadata().is_ok_and(|m| m.file_type().is_symlink());
files.retain(|p| !may_be_made(p) || !made.contains(&std::fs::canonicalize(p).unwrap_or_else(|_| p.clone())) || p.file_stem().is_some_and(|n| text.contains(&*n.to_string_lossy())));
files.retain(|p| !may_be_made(p) || !made.contains(&dunce::canonicalize(p).unwrap_or_else(|_| p.clone())) || p.file_stem().is_some_and(|n| text.contains(&*n.to_string_lossy())));
// absolute media paths the bundle names (an import from outside the edit's folder becomes its path)
for q in text.split('"').skip(1).step_by(2) {
if q.starts_with('/') && q.len() < 4096 && Path::new(q).extension().and_then(|x| x.to_str()).is_some_and(|x| MEDIA_EXTS.contains(&x.to_ascii_lowercase().as_str())) {
files.push(PathBuf::from(q));
}
}
files.push(std::env::current_exe().ok().and_then(|e| std::fs::canonicalize(e).ok())?);
files.push(std::env::current_exe().ok().and_then(|e| dunce::canonicalize(e).ok())?);
files.sort();
files.dedup();
// the optimized copies there are, listed once: asking each media file for its own read its first and last MiB and
+1 -1
View File
@@ -102,7 +102,7 @@ pub fn bundle_fresh(tsx: &Path, out_js: &Path, o: &CompOpts, portable: Option<&P
remove_work(&work);
copy_dir(&dir, &work.join("src"), 0)?;
drop_tsconfigs(&work.join("src"), 0);
let motion_src = raea_io_home::home().join("sdk/raea/src").canonicalize().map_err(|e| format!("raea/motion/src: {e}"))?;
let motion_src = dunce::canonicalize(&raea_io_home::home().join("sdk/raea/src")).map_err(|e| format!("raea/motion/src: {e}"))?;
copy_dir(&motion_src, &work.join("motion"), 0)?;
let sdks = sdks();
for rel in sources(&work.join("motion"))? {
+1 -1
View File
@@ -68,7 +68,7 @@ pub fn rewrite_into(src: &str, from_dir: &Path, motion_src: &Path, to_motion: &s
if !path.exists() {
return Err(format!("line {line}: {spec} doesn't exist (imported media resolves beside the edit)"));
}
let path = path.canonicalize().map_err(|e| e.to_string())?;
let path = dunce::canonicalize(&path).map_err(|e| e.to_string())?;
match portable {
Some(dir) => {
let name = path.file_name().unwrap().to_string_lossy().to_string();
+1
View File
@@ -7,6 +7,7 @@ publish = false
description = "A composition rendered to frames and files: React stepped frame by frame, its pages, 3D and sound made into one raea-render program; and its commits baked by frame"
[dependencies]
dunce = "1"
raea-runtime-view = { path = "../view" }
raea-io-assets = { path = "../../io/assets" }
raea-runtime-react = { path = "../../runtime/react", default-features = false }
+2 -2
View File
@@ -28,7 +28,7 @@ pub fn render(args: &[String]) -> R<String> {
if args.iter().any(|a| a == "--clay") {
raea_runtime_scene3d::clay::CLAY.store(true, std::sync::atomic::Ordering::Relaxed);
}
let tsx = PathBuf::from(&args[1]).canonicalize().map_err(|e| format!("{}: {e}", args[1]))?;
let tsx = dunce::canonicalize(&PathBuf::from(&args[1])).map_err(|e| format!("{}: {e}", args[1]))?;
let out = PathBuf::from(flag(args, "-o").ok_or("-o OUT.mp4|OUT.png|DIR")?);
let dir = tsx.parent().unwrap().to_path_buf();
let js = std::env::temp_dir().join(format!("raea-cli-{}.js", std::process::id()));
@@ -121,7 +121,7 @@ pub fn render(args: &[String]) -> R<String> {
if let Some(d) = c.parent() {
prune_cache(d, "mp4", 16);
// this export is an output: later keys leave it out of the edit's folder
if let Ok(abs) = std::fs::canonicalize(&out) {
if let Ok(abs) = dunce::canonicalize(&out) {
use std::io::Write as _;
if let Ok(mut f) = std::fs::OpenOptions::new().create(true).append(true).open(d.join("outputs.list")) {
let _ = writeln!(f, "{}", abs.display());
+1 -1
View File
@@ -10,7 +10,7 @@ use crate::scene::items;
use raea_core_review::{TILE_W, VIEWS, boxes_of, cameras, ceiling, inside, parts_box, passed, whole};
pub fn review(args: &[String], dir_out: &Path) -> R<String> {
let tsx = PathBuf::from(&args[1]).canonicalize().map_err(|e| format!("{}: {e}", args[1]))?;
let tsx = dunce::canonicalize(&PathBuf::from(&args[1])).map_err(|e| format!("{}: {e}", args[1]))?;
let dir = tsx.parent().unwrap().to_path_buf();
let frame = crate::scene::frame_of(args)?;
std::fs::create_dir_all(dir_out).map_err(|e| format!("{}: {e}", dir_out.display()))?;
+2 -2
View File
@@ -41,7 +41,7 @@ pub fn cli(args: &[String]) -> Result<String, String> {
if mode != "lint" && mode != "explain" {
return Err(usage.into());
}
let tsx = std::path::PathBuf::from(edit).canonicalize().map_err(|e| format!("{edit}: {e}"))?;
let tsx = dunce::canonicalize(&std::path::PathBuf::from(edit)).map_err(|e| format!("{edit}: {e}"))?;
let dir = tsx.parent().unwrap().to_path_buf();
let frame = frame_of(args)?;
let js = std::env::temp_dir().join(format!("raea-scene-{}.js", std::process::id()));
@@ -91,7 +91,7 @@ fn frames_of(args: &[String], tsx: &std::path::Path, comp: &str) -> Result<(Vec<
fn light(args: &[String]) -> Result<String, String> {
let usage = "raea scene light EDIT.tsx [--composition ID[,ID...]] [--frame N|last] [--part NAME] [--json]";
let Some(edit) = args.get(2) else { return Err(usage.into()) };
let tsx = std::path::PathBuf::from(edit).canonicalize().map_err(|e| format!("{edit}: {e}"))?;
let tsx = dunce::canonicalize(&std::path::PathBuf::from(edit)).map_err(|e| format!("{edit}: {e}"))?;
let flag = |k: &str| flag(args, k);
let comps: Vec<String> = flag("--composition").map(|c| c.split(',').map(str::to_string).collect()).unwrap_or_else(|| vec![String::new()]);
let part = flag("--part");
+1
View File
@@ -7,6 +7,7 @@ publish = false
description = "A composition stepped live at the display's rate: its page, 3D and sound each frame, with the person's keys and pointer"
[dependencies]
dunce = "1"
raea-runtime-react = { path = "../../runtime/react", default-features = false }
raea-runtime-page = { path = "../page" }
raea-runtime-sound = { path = "../sound", default-features = false }
+3 -3
View File
@@ -17,7 +17,7 @@ impl Live {
// the thread that steps and presents live frames, at the frame threads' QoS (as the JS thread)
raea_runtime_react::interactive_thread();
raea_io_trace::event("open", serde_json::json!({"composition": tsx, "stage": [stage.0, stage.1]}));
let tsx = tsx.canonicalize().map_err(|e| format!("{}: {e}", tsx.display()))?;
let tsx = dunce::canonicalize(&tsx).map_err(|e| format!("{}: {e}", tsx.display()))?;
let dir = tsx.parent().unwrap().to_path_buf();
let js = std::env::temp_dir().join(format!("raea-live-{}-{:x}.js", std::process::id(), rand_id()));
// the project's words and perception, as a render passes them (captions, regions)
@@ -46,7 +46,7 @@ impl Live {
raea_runtime_react::interactive_thread();
let tmp = std::env::temp_dir().join(format!("raea-live-{}-{:x}.js", std::process::id(), rand_id()));
std::fs::copy(js, &tmp).map_err(|e| format!("{}: {e}", js.display()))?;
Self::from_bundle(tmp, dir.canonicalize().map_err(|e| format!("{}: {e}", dir.display()))?, stage, responsive)
Self::from_bundle(tmp, dunce::canonicalize(&dir).map_err(|e| format!("{}: {e}", dir.display()))?, stage, responsive)
}
/// The game's master as worked out ahead of time (an exported game carries it): no second React at run time.
@@ -88,7 +88,7 @@ impl Live {
/// it, then the frames after). The page is the composition's own size.
pub fn open_baked(tsx: &Path) -> R<Live> {
warm_audio();
let tsx = tsx.canonicalize().map_err(|e| format!("{}: {e}", tsx.display()))?;
let tsx = dunce::canonicalize(&tsx).map_err(|e| format!("{}: {e}", tsx.display()))?;
let dir = tsx.parent().unwrap().to_path_buf();
*raea_runtime_react::native::ASSET_DIR.lock().unwrap() = Some(dir.clone());
let js = std::env::temp_dir().join(format!("raea-live-{}-{:x}.js", std::process::id(), rand_id()));