mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 06:53:19 -10:00
Windows: canonicalize goes through dunce and the home folder through user_home (all but five crates)
canonicalize() through std gives \\?\C:\... on Windows: a path Git for Windows can neither read nor lock, Rolldown can't resolve, and which shares no root with the C:\... git and everything else print. It broke a new workspace's git config (fixed in apps/workspace earlier today). Here the calls in the apps (CapCut, check, direction, engines, fingerprint, game, interchange, judge, solid, sound, targets, tools), the bundler, the CLI, the modules loader, the native shim's realpath, the page's motion, io (assets, gen, home, shell), runtime/bundle/lib, js, track and world, the systems (fingerprint-use, footage, index, ml, page-net), the bridge bench's examples and the sdk/ui test tools use dunce::canonicalize, which gives C:\... wherever a path can be said so and is std's own call on the Mac and Linux.
Reads of the home folder took HOME alone, which Windows doesn't set for an app opened from the Start menu or Explorer, so the taste file, the settings file, the inbox, the npm store, the caches (sounds, splats, goo, ingest, speech, Core ML, the portable perceive models), the node shim's os.homedir() and CapCut's drafts were looked for under whatever folder raea ran in. raea_io_home::user_home() reads HOME, then USERPROFILE (Git for Windows' order; an empty one counts as unset), and models(), caches(), logs(), env_path() and offline() use it, as do the places that had their own fallback.
The caches that had their own copy of "this variable, else this folder under home" (splats, goo, ingest, the npm store, Core ML's models) now call raea_io_home::env_path and models(), and raea_io_home::real canonicalizes a path or keeps it as given, so tools/dupes.max comes down to 289 exact and 58 near. tools/skills.sh reads a variable from env_path("RAEA_...", ".raea/...") as it did from env::var, so files.md keeps RAEA_NPM_HOME on ~/.raea/npm (every generated reference is unchanged).
Five crates hold other sessions' uncommitted edits (engine/page/stage, engine/render, runtime/bundle, runtime/export, runtime/live): their few calls, and tools/windows-paths.sh, the check that keeps both at zero, land once those are committed.
Checked: cargo check --all-targets of every crate changed, and of sdk/ui/conformance and sdk/ui/parity. On a Windows 11 PC and on macOS the unit tests of raea-io-home (user_home's order and an empty HOME, now in caches_logs_and_the_home_folder_follow_the_platform), raea-app-check, raea-app-workspace, raea-app-registry and raea-core-facts pass (5, 27, 10, 7, 17).
This commit is contained in:
1 parent
a927fbb027
commit
57f3ef8db3
145 files changed
+283
-143
No files matched your search
Generated
+47
@@ -13745,6 +13745,7 @@ checksum = "019b4b213425016d7d84a153c4c73afb0946fbb4840e4eece7ba8848b9d6da22"
|
||||
name = "raea-app-capcut"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-scene",
|
||||
"raea-io-alpha",
|
||||
@@ -13759,11 +13760,13 @@ dependencies = [
|
||||
name = "raea-app-check"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-app-check-flash",
|
||||
"raea-app-check-inbox",
|
||||
"raea-core-brief",
|
||||
"raea-core-facts",
|
||||
"raea-io-ffmpeg",
|
||||
"raea-io-home",
|
||||
"raea-io-trace",
|
||||
"raea-sys-measure",
|
||||
"serde_json",
|
||||
@@ -13794,11 +13797,13 @@ dependencies = [
|
||||
name = "raea-app-direction"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-app-check",
|
||||
"raea-app-notes",
|
||||
"raea-app-registry",
|
||||
"raea-core-brief",
|
||||
"raea-core-facts",
|
||||
"raea-io-home",
|
||||
"raea-io-trace",
|
||||
"raea-runtime-bundle",
|
||||
"raea-runtime-react",
|
||||
@@ -13826,8 +13831,10 @@ name = "raea-app-fingerprint"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dunce",
|
||||
"fastrand",
|
||||
"raea-app-check",
|
||||
"raea-io-home",
|
||||
"raea-sys-columns",
|
||||
"raea-sys-fingerprint",
|
||||
"raea-sys-fingerprint-things",
|
||||
@@ -13841,6 +13848,7 @@ name = "raea-app-game"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"dunce",
|
||||
"raea-gpu-device",
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
@@ -13859,6 +13867,7 @@ dependencies = [
|
||||
name = "raea-app-interchange"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-core-scene",
|
||||
"raea-core-shape",
|
||||
"raea-runtime-bundle",
|
||||
@@ -13872,6 +13881,7 @@ name = "raea-app-judge"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-facts",
|
||||
"raea-io-home",
|
||||
@@ -13899,6 +13909,7 @@ name = "raea-app-notes"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-core-facts",
|
||||
"raea-io-home",
|
||||
"raea-io-trace",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -13930,6 +13941,7 @@ dependencies = [
|
||||
"dunce",
|
||||
"oxc",
|
||||
"raea-core-facts",
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -13937,6 +13949,7 @@ dependencies = [
|
||||
name = "raea-app-solid"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-app-judge",
|
||||
"raea-core-facts",
|
||||
"raea-core-meshcheck",
|
||||
@@ -13950,6 +13963,7 @@ dependencies = [
|
||||
name = "raea-app-sound"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-io-media",
|
||||
"raea-runtime-bundle",
|
||||
"raea-runtime-export",
|
||||
@@ -13961,6 +13975,7 @@ name = "raea-app-targets"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"dunce",
|
||||
"raea-io-home",
|
||||
"raea-runtime-bundle",
|
||||
"serde_json",
|
||||
@@ -13970,6 +13985,7 @@ dependencies = [
|
||||
name = "raea-app-tools"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-io-assets",
|
||||
"raea-io-gen",
|
||||
"raea-io-home",
|
||||
@@ -13989,6 +14005,7 @@ dependencies = [
|
||||
"raea-app-registry",
|
||||
"raea-core-brief",
|
||||
"raea-core-facts",
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -14060,6 +14077,7 @@ dependencies = [
|
||||
"chacha20 0.10.2",
|
||||
"indexmap",
|
||||
"nonmax",
|
||||
"raea-io-home",
|
||||
"raea-sys-parity",
|
||||
"rand 0.10.3",
|
||||
]
|
||||
@@ -14143,6 +14161,7 @@ name = "raea-bridge-bench"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-alloc",
|
||||
"raea-core-wire",
|
||||
@@ -14167,6 +14186,7 @@ name = "raea-bundle"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dunce",
|
||||
"lightningcss",
|
||||
"oxc",
|
||||
"raea-io-home",
|
||||
@@ -14202,6 +14222,7 @@ name = "raea-cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"dunce",
|
||||
"raea-app-capcut",
|
||||
"raea-app-check",
|
||||
"raea-app-ci",
|
||||
@@ -14460,6 +14481,7 @@ dependencies = [
|
||||
name = "raea-io-assets"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-io-home",
|
||||
"ruzstd",
|
||||
@@ -14482,6 +14504,7 @@ dependencies = [
|
||||
name = "raea-io-capcut"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -14510,6 +14533,7 @@ dependencies = [
|
||||
name = "raea-io-gen"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-io-gen-comfy",
|
||||
"raea-io-gen-core",
|
||||
@@ -14549,6 +14573,7 @@ dependencies = [
|
||||
name = "raea-io-home"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"serde_json",
|
||||
"url",
|
||||
]
|
||||
@@ -14626,6 +14651,7 @@ dependencies = [
|
||||
name = "raea-io-shell"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"flate2",
|
||||
"htmd",
|
||||
"raea-core-calls",
|
||||
@@ -14666,6 +14692,7 @@ name = "raea-modules"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"deno_ast",
|
||||
"dunce",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -14673,10 +14700,12 @@ name = "raea-native"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"dunce",
|
||||
"flate2",
|
||||
"getrandom 0.3.4",
|
||||
"libc",
|
||||
"raea-core-calls",
|
||||
"raea-io-home",
|
||||
"raea-io-shell",
|
||||
"raea-modules",
|
||||
"raea-runtime-jsengine",
|
||||
@@ -14701,6 +14730,7 @@ dependencies = [
|
||||
"bevy",
|
||||
"blitz-dom",
|
||||
"blitz-html",
|
||||
"dunce",
|
||||
"image",
|
||||
"parley",
|
||||
"raea-core-wire",
|
||||
@@ -15046,6 +15076,7 @@ dependencies = [
|
||||
name = "raea-runtime-bundle-lib"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"libloading",
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
@@ -15234,6 +15265,7 @@ dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bevy",
|
||||
"cpal 0.15.3",
|
||||
"dunce",
|
||||
"raea-bevy-world",
|
||||
"raea-core-wire",
|
||||
"raea-io-home",
|
||||
@@ -15252,6 +15284,7 @@ name = "raea-runtime-jsengine"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"objc2 0.6.5",
|
||||
"raea-io-home",
|
||||
"rquickjs",
|
||||
]
|
||||
|
||||
@@ -15466,6 +15499,7 @@ dependencies = [
|
||||
name = "raea-runtime-track"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-io-assets",
|
||||
"raea-native",
|
||||
"raea-runtime-bundle",
|
||||
@@ -15519,6 +15553,7 @@ name = "raea-runtime-world"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-facts",
|
||||
"raea-core-scene",
|
||||
@@ -15583,6 +15618,7 @@ name = "raea-sys-bake"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
"raea-io-home",
|
||||
"rapier3d",
|
||||
"serde_json",
|
||||
"sha2 0.10.9",
|
||||
@@ -15621,6 +15657,7 @@ dependencies = [
|
||||
"half",
|
||||
"image",
|
||||
"ort",
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
"raea-sys-ml",
|
||||
"rustfft",
|
||||
@@ -15694,6 +15731,7 @@ name = "raea-sys-fingerprint"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"raea-io-home",
|
||||
"raea-sys-columns",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -15717,6 +15755,7 @@ name = "raea-sys-fingerprint-use"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dunce",
|
||||
"fastrand",
|
||||
"image",
|
||||
"raea-sys-columns",
|
||||
@@ -15769,7 +15808,9 @@ dependencies = [
|
||||
name = "raea-sys-footage"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
"raea-sys-layout",
|
||||
"raea-sys-song",
|
||||
@@ -15854,6 +15895,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"block2 0.6.2",
|
||||
"dunce",
|
||||
"half",
|
||||
"objc2 0.6.5",
|
||||
"objc2-app-kit 0.3.2",
|
||||
@@ -15896,6 +15938,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"mlx-rs",
|
||||
"raea-io-home",
|
||||
"raea-sys-ml",
|
||||
"raea-sys-mlx",
|
||||
"serde_json",
|
||||
@@ -16014,6 +16057,7 @@ name = "raea-sys-ml"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dunce",
|
||||
"half",
|
||||
"ort",
|
||||
"raea-io-home",
|
||||
@@ -16060,6 +16104,7 @@ dependencies = [
|
||||
"bevy",
|
||||
"blitz-dom",
|
||||
"blitz-traits",
|
||||
"dunce",
|
||||
"percent-encoding",
|
||||
"raea-io-net",
|
||||
"raea-sys-image",
|
||||
@@ -16210,6 +16255,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ort",
|
||||
"raea-io-home",
|
||||
"raea-sys-ml",
|
||||
"serde_json",
|
||||
"tokenizers",
|
||||
@@ -16302,6 +16348,7 @@ dependencies = [
|
||||
"objc2-core-video",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-vision",
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
"raea-sys-layout",
|
||||
"serde",
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "`raea export capcut`: a composition as a CapCut draft ready in its timeline, its footage and sounds as clips of their files and what raea draws as transparent overlays (docs/capcut.feature)"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
raea-io-capcut = { path = "../../io/capcut" }
|
||||
raea-io-alpha = { path = "../../io/alpha" }
|
||||
|
||||
@@ -64,7 +64,7 @@ fn render(args: &[String], env: &[(&str, &str)]) -> R<()> {
|
||||
|
||||
fn export(args: &[String]) -> R<String> {
|
||||
let tsx = args.first().filter(|a| !a.starts_with('-')).ok_or(USAGE)?;
|
||||
let tsx = PathBuf::from(tsx).canonicalize().map_err(|e| format!("{tsx}: {e}"))?;
|
||||
let tsx = dunce::canonicalize(&PathBuf::from(tsx)).map_err(|e| format!("{tsx}: {e}"))?;
|
||||
let dir = tsx.parent().unwrap().to_path_buf();
|
||||
let codec = flag(args, "--alpha-codec").map_or(Ok(raea_io_alpha::Codec::default_here()), |c| raea_io_alpha::Codec::parse(&c))?;
|
||||
let (root, in_store) = match flag(args, "-o") {
|
||||
|
||||
@@ -178,5 +178,5 @@ pub fn lay(kind: Kind, name: &str, clips: Vec<Clip>) -> Vec<Track> {
|
||||
/// media/, then the project's media/ and assets/; else absolute; else relative to the composition's folder.
|
||||
pub fn resolve(dir: &Path, src: &str) -> PathBuf {
|
||||
let p = raea_core_scene::media_path(dir, src);
|
||||
p.canonicalize().unwrap_or(p)
|
||||
dunce::canonicalize(&p).unwrap_or(p)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ fn a_static_file_is_found_in_the_edits_media_folder() {
|
||||
let dir = std::env::temp_dir().join(format!("raea-capcut-resolve-{}", std::process::id()));
|
||||
std::fs::create_dir_all(dir.join("media")).unwrap();
|
||||
std::fs::write(dir.join("media/a.mp4"), "").unwrap();
|
||||
let want = dir.join("media/a.mp4").canonicalize().unwrap();
|
||||
let want = dunce::canonicalize(&dir.join("media/a.mp4")).unwrap();
|
||||
assert_eq!(resolve(&dir, "/media/a.mp4"), want);
|
||||
assert_eq!(resolve(&dir, "media/a.mp4"), want);
|
||||
assert_eq!(resolve(&dir, want.to_str().unwrap()), want);
|
||||
|
||||
@@ -7,10 +7,12 @@ publish = false
|
||||
description = "`raea check`: the floor's measurable lines on an export, ranked P0-P3"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
# taste.ts rules, as the raea CLI evaluates them (docs/projects.feature PJ0)
|
||||
raea-core-brief = { path = "../../core/brief" }
|
||||
# a transcript's words, read as `raea world` reads them (docs/direction.feature DR1)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# a check's record named by when it was (UTC, DR3)
|
||||
raea-io-trace = { path = "../../io/trace" }
|
||||
# ffmpeg's flag for every decoded frame, by its version
|
||||
|
||||
@@ -154,7 +154,7 @@ pub fn hook(args: &[String]) -> R<String> {
|
||||
}
|
||||
let after_tool = matches!(event, "PostToolUse" | "AfterTool");
|
||||
if let Some(cmd) = shell_command(&v).filter(|_| !after_tool) {
|
||||
let home = std::env::var("HOME").unwrap_or_default();
|
||||
let home = raea_io_home::user_home().unwrap_or_default().display().to_string();
|
||||
let files = opened_media(cmd);
|
||||
let key = format!("{}\n{}\n{cmd}", v["session_id"].as_str().unwrap_or(""), v["cwd"].as_str().unwrap_or(""));
|
||||
if !files.is_empty() && app_installed(&home) && !tried_before(&PathBuf::from(&home).join(".raea/hooks/again"), &key) {
|
||||
|
||||
@@ -22,7 +22,7 @@ pub(crate) struct Run {
|
||||
pub(crate) fn brand_kit(near: &[&str], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
for start in near.iter().filter(|p| !p.is_empty()) {
|
||||
let abs = std::path::Path::new(start).canonicalize().unwrap_or_else(|_| std::path::PathBuf::from(start));
|
||||
let abs = dunce::canonicalize(&std::path::Path::new(start)).unwrap_or_else(|_| std::path::PathBuf::from(start));
|
||||
let mut d = abs.parent();
|
||||
for _ in 0..5 {
|
||||
let Some(here) = d else { break };
|
||||
|
||||
@@ -7,6 +7,8 @@ publish = false
|
||||
description = "How raea takes direction (docs/direction.feature): `raea world`, a composition's frame as one world of facts, queried across media"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
raea-runtime-world = { path = "../../runtime/world" }
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
|
||||
@@ -32,7 +32,7 @@ pub struct Host {
|
||||
|
||||
/// The person's taste folder: RAEA_TASTE, else ~/.raea/taste.
|
||||
pub fn taste_dir() -> Option<PathBuf> {
|
||||
std::env::var_os("RAEA_TASTE").map(PathBuf::from).or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".raea/taste")))
|
||||
std::env::var_os("RAEA_TASTE").map(PathBuf::from).or_else(|| raea_io_home::user_home().map(|h| h.join(".raea/taste")))
|
||||
}
|
||||
|
||||
/// The .ts files `--taste` names: the file, or every .ts in the folder. A file named under the person's taste folder
|
||||
@@ -133,12 +133,12 @@ fn held(project: &Path, given: Vec<PathBuf>, host: &Host) -> (Vec<Rule>, Vec<Fin
|
||||
/// The compositions `target` names: each (its file, its id when the file registers several).
|
||||
fn compositions(target: &Path, args: &[String]) -> R<Vec<(PathBuf, Option<String>)>> {
|
||||
let one = flag(args, "--composition");
|
||||
let (dir, file) = if target.is_dir() { (target.to_path_buf(), None) } else { (target.parent().unwrap_or(Path::new(".")).to_path_buf(), Some(target.canonicalize().map_err(|e| format!("{}: {e}", target.display()))?)) };
|
||||
let (dir, file) = if target.is_dir() { (target.to_path_buf(), None) } else { (target.parent().unwrap_or(Path::new(".")).to_path_buf(), Some(dunce::canonicalize(&target).map_err(|e| format!("{}: {e}", target.display()))?)) };
|
||||
let reg = raea_app_registry::scan(&dir, &[]);
|
||||
let mut out: Vec<(PathBuf, Option<String>)> = Vec::new();
|
||||
for c in ®.compositions {
|
||||
let path = reg.dir.join(&c.file);
|
||||
let path = path.canonicalize().unwrap_or(path);
|
||||
let path = dunce::canonicalize(&path).unwrap_or(path);
|
||||
let id = (c.how == raea_app_registry::How::Registered).then(|| c.id.clone());
|
||||
if file.as_ref().is_none_or(|f| *f == path) && one.as_ref().is_none_or(|o| Some(o) == id.as_ref()) {
|
||||
out.push((path, id));
|
||||
@@ -325,7 +325,7 @@ pub fn check(args: &[String], host: &Host) -> R<(String, bool)> {
|
||||
let target = raea_app_check::words(args, &TAKES).first().map_or_else(|| PathBuf::from("."), PathBuf::from);
|
||||
// the folder it is in, made whole (`lyric.tsx`'s is the empty path): a rule's check is a path from it
|
||||
let here = if target.is_dir() { target.clone() } else { target.parent().filter(|p| !p.as_os_str().is_empty()).map_or_else(|| PathBuf::from("."), Path::to_path_buf) };
|
||||
let here = here.canonicalize().map_err(|e| format!("{}: {e}", here.display()))?;
|
||||
let here = dunce::canonicalize(&here).map_err(|e| format!("{}: {e}", here.display()))?;
|
||||
let project = record::up(&here, ".raea/project").unwrap_or(here);
|
||||
let (mut rules, unread, notes) = rules(&project, taste_files(args), host);
|
||||
if let Some(only) = flag(args, "--only") {
|
||||
|
||||
@@ -84,7 +84,7 @@ pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
}
|
||||
let target = args.get(1).filter(|a| !a.starts_with("--")).map_or_else(|| PathBuf::from("."), PathBuf::from);
|
||||
// made absolute first: a bare name's parent is "", which names no folder
|
||||
let from = if target.is_file() { target.canonicalize().unwrap_or_else(|_| target.clone()).parent().map_or_else(|| PathBuf::from("."), Path::to_path_buf) } else { target.clone() };
|
||||
let from = if target.is_file() { dunce::canonicalize(&target).unwrap_or_else(|_| target.clone()).parent().map_or_else(|| PathBuf::from("."), Path::to_path_buf) } else { target.clone() };
|
||||
let project = record::up(&from, ".raea/project").ok_or_else(|| format!("raea findings: {} isn't in a raea project (no .raea/project at or above it), so nothing is recorded\n{USAGE}", target.display()))?;
|
||||
let (about, check, since) = (flag(args, "--about"), flag(args, "--check"), flag(args, "--since"));
|
||||
let keep = |f: &Finding| about.as_deref().is_none_or(|n| f.about.iter().any(|a| a.name == n || a.key.as_deref() == Some(n))) && check.as_deref().is_none_or(|c| f.check == c);
|
||||
|
||||
@@ -69,7 +69,7 @@ pub fn run(files: &[PathBuf], plan: &[Planned], worlds: &[Facts], host: &Host) -
|
||||
std::fs::create_dir_all(&work).map_err(|e| e.to_string())?;
|
||||
let data = work.join("worlds.json");
|
||||
std::fs::write(&data, serde_json::to_string(worlds).map_err(|e| e.to_string())?).map_err(|e| e.to_string())?;
|
||||
let imports: String = files.iter().enumerate().map(|(i, f)| format!("import c{i} from {:?};\n", f.canonicalize().unwrap_or_else(|_| f.clone()).display().to_string())).collect();
|
||||
let imports: String = files.iter().enumerate().map(|(i, f)| format!("import c{i} from {:?};\n", dunce::canonicalize(&f).unwrap_or_else(|_| f.clone()).display().to_string())).collect();
|
||||
let checks = (0..files.len()).map(|i| format!("c{i}")).collect::<Vec<_>>().join(", ");
|
||||
let planned: Vec<Value> = plan.iter().map(|p| json!({"check": p.check, "frames": p.frames, "values": p.values, "level": p.level, "by": p.by})).collect();
|
||||
let entry = format!(
|
||||
|
||||
@@ -47,7 +47,7 @@ pub(crate) fn spec(p: &Path) -> String {
|
||||
}
|
||||
|
||||
pub fn run(args: &[String]) -> R<String> {
|
||||
let ts = PathBuf::from(&args[2]).canonicalize().map_err(|e| format!("{}: {e}", args[2]))?;
|
||||
let ts = dunce::canonicalize(&PathBuf::from(&args[2])).map_err(|e| format!("{}: {e}", args[2]))?;
|
||||
let file = args.get(3).filter(|a| a.ends_with(".blend")).map(PathBuf::from);
|
||||
// ARGS for Blender's sys.argv, without raea's own --timeout SECS
|
||||
let mut rest = args[if file.is_some() { 4 } else { 3 }..].to_vec();
|
||||
|
||||
@@ -197,7 +197,7 @@ pub fn setup(args: &[String]) -> R<String> {
|
||||
/// The project folder: DIR, else the current folder; it needs its project.godot.
|
||||
fn project(arg: Option<&String>) -> R<PathBuf> {
|
||||
let dir = arg.map(PathBuf::from).unwrap_or_else(|| PathBuf::from("."));
|
||||
let dir = dir.canonicalize().map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
let dir = dunce::canonicalize(&dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
if !dir.join("project.godot").is_file() {
|
||||
return Err(format!("{} has no project.godot", dir.display()));
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ fn opts(args: &[String]) -> R<Opts> {
|
||||
let script = args.get(2).ok_or("raea godot run SCRIPT.ts [--project DIR] [--window] [--movie FILE [--fps N] [--frames N]] [--scene res://X.tscn] [--size WxH] [--timeout S] [ARGS...]")?;
|
||||
// no script, only flags: the project's --scene plays with nothing of yours added (sdk/godot/src/host/none.ts)
|
||||
let bare = script.starts_with("--");
|
||||
let script = if bare { raea_io_home::home().join("sdk/godot/src/host/none.ts") } else { PathBuf::from(script).canonicalize().map_err(|e| format!("{script}: {e}"))? };
|
||||
let script = if bare { raea_io_home::home().join("sdk/godot/src/host/none.ts") } else { dunce::canonicalize(&PathBuf::from(script)).map_err(|e| format!("{script}: {e}"))? };
|
||||
let mut o = Opts { script, project: None, window: false, timeout: 3600.0, movie: None, fps: 30, size: None, frames: None, scene: None, rest: Vec::new() };
|
||||
let mut it = args[if bare { 2 } else { 3 }..].iter();
|
||||
while let Some(a) = it.next() {
|
||||
@@ -176,7 +176,7 @@ pub fn run(args: &[String]) -> R<String> {
|
||||
}
|
||||
// the project: --project, the nearest project.godot above the script, else an empty one for this run
|
||||
let found = match &o.project {
|
||||
Some(p) => Some(p.canonicalize().map_err(|e| format!("{}: {e}", p.display()))?),
|
||||
Some(p) => Some(dunce::canonicalize(&p).map_err(|e| format!("{}: {e}", p.display()))?),
|
||||
None => nearest_project(o.script.parent().unwrap_or(Path::new("."))),
|
||||
};
|
||||
let temp = std::env::temp_dir().join(format!("raea-godot-{}", std::process::id()));
|
||||
|
||||
@@ -69,7 +69,7 @@ pub fn godot_export(args: &[String]) -> R<String> {
|
||||
}
|
||||
|
||||
pub fn godot_back(args: &[String]) -> R<String> {
|
||||
let dir = PathBuf::from(args.get(2).ok_or(USAGE)?).canonicalize().map_err(|e| format!("{}: {e}", args[2]))?;
|
||||
let dir = dunce::canonicalize(&PathBuf::from(args.get(2).ok_or(USAGE)?)).map_err(|e| format!("{}: {e}", args[2]))?;
|
||||
let media = media_of(&dir)?;
|
||||
let now = dir.join(".raea-now.json");
|
||||
let script = raea_io_home::home().join("sdk/godot/src/host/back.ts");
|
||||
@@ -129,7 +129,7 @@ pub fn blender_open(args: &[String]) -> R<String> {
|
||||
}
|
||||
|
||||
pub fn blender_back(args: &[String]) -> R<String> {
|
||||
let blend = PathBuf::from(args.get(2).filter(|a| a.ends_with(".blend")).ok_or(USAGE)?).canonicalize().map_err(|e| format!("{}: {e}", args[2]))?;
|
||||
let blend = dunce::canonicalize(&PathBuf::from(args.get(2).filter(|a| a.ends_with(".blend")).ok_or(USAGE)?)).map_err(|e| format!("{}: {e}", args[2]))?;
|
||||
let dir = blend.parent().ok_or("the .blend's folder")?.to_path_buf();
|
||||
if !dir.join("scene.json").is_file() {
|
||||
return Err(format!("{} has no scene.json beside it: raea blender back reads a .blend raea blender open made", blend.display()));
|
||||
|
||||
@@ -113,7 +113,7 @@ pub fn blender(args: &[String]) -> R<String> {
|
||||
let entry = if is_blend {
|
||||
format!("{shoot}Promise.resolve().then(() => shoot({opts})){}\n", blender_ts::CLOSE)
|
||||
} else {
|
||||
let ts = src.canonicalize().map_err(|e| format!("{}: {e}", s.src))?;
|
||||
let ts = dunce::canonicalize(&src).map_err(|e| format!("{}: {e}", s.src))?;
|
||||
format!("import * as M from {};\n{shoot}{}.then(() => shoot({opts})){}\n", blender_ts::spec(&ts), blender_ts::DEFAULT, blender_ts::CLOSE)
|
||||
};
|
||||
let mut rest = s.rest.clone();
|
||||
|
||||
@@ -7,6 +7,8 @@ publish = false
|
||||
description = "`raea fingerprint` (docs/fingerprint.feature FP3a): new, bootstrap, teach, score and report, run by a resident service on localhost that keeps the encoders loaded"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# the taxonomy, evidence and heads
|
||||
raea-sys-fingerprint = { path = "../../systems/fingerprint" }
|
||||
# scoring and the sheet, which one judges a piece, diff and profiles
|
||||
|
||||
@@ -23,7 +23,7 @@ pub const INBOX: &str = "fingerprint";
|
||||
/// A post's video on this machine: the renders library, else the project's own folder
|
||||
fn media(project: &Path, m: &Value) -> Option<PathBuf> {
|
||||
let p = m["path"].as_str()?;
|
||||
let home = PathBuf::from(std::env::var("HOME").unwrap_or_default());
|
||||
let home = raea_io_home::user_home().unwrap_or_default();
|
||||
[home.join(".raea/feed/media").join(p), project.join(p)].into_iter().find(|f| f.is_file())
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ pub(crate) fn readings_here(args: &[String], cwd: &Path) -> i32 {
|
||||
}
|
||||
if has(args, "--tally") {
|
||||
let asked: serde_json::Map<String, Value> = std::fs::read(dir.dir.join("asked.json")).ok().and_then(|b| serde_json::from_slice(&b).ok()).unwrap_or_default();
|
||||
let inbox = PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(format!(".raea/inbox/{INBOX}.jsonl"));
|
||||
let inbox = raea_io_home::user_home().unwrap_or_default().join(format!(".raea/inbox/{INBOX}.jsonl"));
|
||||
for line in std::fs::read_to_string(inbox).unwrap_or_default().lines() {
|
||||
let Ok(v) = serde_json::from_str::<Value>(line) else { continue };
|
||||
let Some(batch) = v["item"].as_str().and_then(|i| asked.get(i)).and_then(Value::as_array) else { continue };
|
||||
|
||||
@@ -10,7 +10,7 @@ use raea_sys_fingerprint::evidence::{Row, features};
|
||||
use raea_sys_fingerprint::retrain;
|
||||
use raea_sys_fingerprint_use::postmortem::{self as pm, MOST};
|
||||
use raea_sys_fingerprint_use::score::{Scored, score};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
|
||||
pub(crate) fn run(enc: &mut Encoders, args: &[String], cwd: &Path, eval: Eval) -> Result<(String, i32)> {
|
||||
let project = crate::pick::piece_in(args, cwd).parent().map(Path::to_path_buf).unwrap_or_else(|| cwd.to_path_buf());
|
||||
@@ -18,7 +18,7 @@ pub(crate) fn run(enc: &mut Encoders, args: &[String], cwd: &Path, eval: Eval) -
|
||||
let (dir, fp, w) = crate::verbs::open(enc, args, eval, Some(&crate::pick::piece_in(args, cwd)))?;
|
||||
let before = dir.trained()?.map(|t| t.0).ok_or_else(|| anyhow!("{} has no trained heads yet: `raea fingerprint bootstrap` or teach it first", fp.name))?;
|
||||
if has(args, "--tally") {
|
||||
let inbox = std::fs::read_to_string(PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(format!(".raea/inbox/{}.jsonl", pm::INBOX))).unwrap_or_default();
|
||||
let inbox = std::fs::read_to_string(raea_io_home::user_home().unwrap_or_default().join(format!(".raea/inbox/{}.jsonl", pm::INBOX))).unwrap_or_default();
|
||||
let answers = pm::answered(&dir.dir, &inbox);
|
||||
let mut l = dir.ledger()?;
|
||||
// every tally adds every answer again, so tallying twice is safe
|
||||
|
||||
@@ -12,10 +12,10 @@ use std::path::{Path, PathBuf};
|
||||
pub(crate) fn run(enc: &mut Encoders, args: &[String], cwd: &Path) -> Result<(String, i32)> {
|
||||
let file = cwd.join(args.first().filter(|a| !a.starts_with("--")).ok_or_else(|| anyhow::anyhow!("things FILE"))?);
|
||||
let project = flag(args, "--project").map_or_else(|| cwd.to_path_buf(), |p| cwd.join(p));
|
||||
let me = file.canonicalize().ok();
|
||||
let me = dunce::canonicalize(&file).ok();
|
||||
let marks: Vec<Mark> = crate::notes::pinned(&project)
|
||||
.into_iter()
|
||||
.filter(|r| r.media.canonicalize().ok() == me)
|
||||
.filter(|r| dunce::canonicalize(&r.media).ok() == me)
|
||||
.filter_map(|r| Some(Mark { name: r.text.chars().take(40).collect(), t: r.t, a: (r.t - 1.0).max(0.0), b: r.to.unwrap_or(r.t + 1.0), region: r.region? }))
|
||||
.collect();
|
||||
let t = things(enc, &file, &marks)?;
|
||||
|
||||
@@ -19,6 +19,7 @@ player = []
|
||||
surfaces = ["raea-runtime-react/surfaces"]
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-runtime-react = { path = "../../runtime/react", default-features = false }
|
||||
raea-runtime-page = { path = "../../runtime/page" }
|
||||
raea-runtime-export = { path = "../../runtime/export" }
|
||||
|
||||
@@ -14,7 +14,7 @@ pub(crate) fn keep_dsym(player: &Path) {
|
||||
let Ok(o) = std::process::Command::new("dwarfdump").arg("--uuid").arg(&dsym).output() else { return };
|
||||
let text = String::from_utf8_lossy(&o.stdout);
|
||||
let Some(uuid) = text.split_whitespace().nth(1).filter(|u| u.len() == 36) else { return };
|
||||
let Some(home) = std::env::var_os("HOME") else { return };
|
||||
let Some(home) = raea_io_home::user_home() else { return };
|
||||
let to = Path::new(&home).join("Library/Caches/raea/dsym").join(uuid).join("raea-game.dSYM");
|
||||
if to.exists() {
|
||||
return;
|
||||
@@ -34,7 +34,7 @@ pub const USAGE: &str = "raea export-game EDIT.tsx -o OUT [--target mac-app|mac-
|
||||
pub fn export(args: &[String]) -> R<String> {
|
||||
let usage = USAGE;
|
||||
let tsx = PathBuf::from(args.get(1).filter(|a| !a.starts_with("--")).ok_or(usage)?);
|
||||
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 out = PathBuf::from(flag(args, "-o").ok_or(usage)?);
|
||||
let target = flag(args, "--target").unwrap_or_else(|| if out.extension().is_some_and(|x| x == "app") { "mac-app".into() } else { "mac-cli".into() });
|
||||
|
||||
@@ -85,7 +85,7 @@ pub(crate) fn gather(bundle: &mut String, dir: &Path, game: &Path, got: &mut Gat
|
||||
}
|
||||
}
|
||||
}
|
||||
let inside = |p: &Path| -> Option<String> { p.canonicalize().ok().and_then(|c| c.strip_prefix(dir.canonicalize().ok()?).ok().map(|r| r.to_string_lossy().to_string())) };
|
||||
let inside = |p: &Path| -> Option<String> { dunce::canonicalize(&p).ok().and_then(|c| c.strip_prefix(dunce::canonicalize(&dir).ok()?).ok().map(|r| r.to_string_lossy().to_string())) };
|
||||
let mut rewrites: Vec<(String, String)> = Vec::new();
|
||||
for s in &lits {
|
||||
if s.contains("://") || s.starts_with("data:") || s.len() < 2 || s.contains('\u{0}') {
|
||||
@@ -134,7 +134,7 @@ pub(crate) fn gather(bundle: &mut String, dir: &Path, game: &Path, got: &mut Gat
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let canon = file.canonicalize().unwrap_or(file.clone());
|
||||
let canon = dunce::canonicalize(&file).unwrap_or(file.clone());
|
||||
let h = twox_hash::XxHash3_64::oneshot(canon.to_string_lossy().as_bytes());
|
||||
let rel = format!("media/_ext/{:08x}-{}", h as u32, file.file_name().unwrap().to_string_lossy());
|
||||
put(&file, &rel, game, got)?;
|
||||
|
||||
@@ -50,11 +50,11 @@ pub(crate) fn find_game(args: &[String]) -> R<PathBuf> {
|
||||
return Ok(PathBuf::from(d));
|
||||
}
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let exe = exe.canonicalize().unwrap_or(exe);
|
||||
let exe = dunce::canonicalize(&exe).unwrap_or(exe);
|
||||
let here = exe.parent().unwrap_or(Path::new("."));
|
||||
for c in [here.join("../Resources/game"), here.join("game")] {
|
||||
if c.join(MANIFEST).exists() {
|
||||
return Ok(c.canonicalize().unwrap_or(c));
|
||||
return Ok(dunce::canonicalize(&c).unwrap_or(c));
|
||||
}
|
||||
}
|
||||
Err(format!("no game beside {} (an exported game's player looks in ../Resources/game or game/; --game DIR names one)", exe.display()))
|
||||
@@ -300,7 +300,7 @@ pub(crate) fn selftest(game: &Game, secs: f64, args: &[String]) -> R<String> {
|
||||
"has_3d": game.has_3d,
|
||||
"snapshots": snapped,
|
||||
"panics": panics,
|
||||
"env": {"home": std::env::var("HOME").unwrap_or_default(), "raea_vars_given": std::env::vars().filter(|(k, _)| k.starts_with("RAEA_") && k != "RAEA_AUDIO_MUTE" && k != "RAEA_AUDIO_TAP").count()},
|
||||
"env": {"home": raea_io_home::user_home().unwrap_or_default().display().to_string(), "raea_vars_given": std::env::vars().filter(|(k, _)| k.starts_with("RAEA_") && k != "RAEA_AUDIO_MUTE" && k != "RAEA_AUDIO_TAP").count()},
|
||||
});
|
||||
if let Some(p) = flag(args, "--json") {
|
||||
std::fs::write(&p, serde_json::to_string_pretty(&report).unwrap()).map_err(|e| format!("{p}: {e}"))?;
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "A composition's 3D as data another tool builds (`raea scene export`: scene.json, its meshes and models), a Godot project written from it, and what changed in Blender or Godot read back as edits to the TSX (docs/blender.feature BL37-BL39, docs/godot.feature GD12-GD13)"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
# the composition bundled and stepped to its frames' 3D (raea-runtime-export's scene_frames), walked into parts
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
raea-runtime-export = { path = "../../runtime/export" }
|
||||
|
||||
@@ -237,7 +237,7 @@ pub fn scene(all: &[Vec<Item>], frames: &[i64], dir: &Path, out: &Path) -> R<Val
|
||||
/// `raea scene export ...`: scene.json written, and its value.
|
||||
pub fn export(args: &[String]) -> R<(PathBuf, Value)> {
|
||||
let edit = args.get(2).ok_or(USAGE)?;
|
||||
let tsx = PathBuf::from(edit).canonicalize().map_err(|e| format!("{edit}: {e}"))?;
|
||||
let tsx = dunce::canonicalize(&PathBuf::from(edit)).map_err(|e| format!("{edit}: {e}"))?;
|
||||
let dir = tsx.parent().ok_or("the edit's folder")?.to_path_buf();
|
||||
let out = args.iter().position(|a| a == "-o").and_then(|i| args.get(i + 1)).ok_or(USAGE)?;
|
||||
let out = std::path::absolute(out).map_err(|e| e.to_string())?;
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "raea judge: a review's sheets judged by clef-omni on a frozen rubric, the pass decided in code, calibrated against the person's eye before it gates"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# what a judge saw, as raea's one Finding (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
|
||||
@@ -84,7 +84,7 @@ pub fn read(v: &Value) -> (Map<String, Value>, Vec<Value>, Value) {
|
||||
/// said on stderr as it comes, so a watcher sees it working through a judgement that can take minutes.
|
||||
pub fn ask(by: &str, dir: &Path, brief: &Value, target: Option<&Path>) -> Result<Value, String> {
|
||||
use std::io::BufRead as _;
|
||||
let dir = dir.canonicalize().map_err(|e| format!("judge: {}: {e}", dir.display()))?;
|
||||
let dir = dunce::canonicalize(&dir).map_err(|e| format!("judge: {}: {e}", dir.display()))?;
|
||||
let p = prompt(&dir, brief, target);
|
||||
let mut cmd = match by {
|
||||
"kimi" => {
|
||||
|
||||
@@ -9,6 +9,7 @@ description = "A person's notes on a project as files the work is held to (docs/
|
||||
[dependencies]
|
||||
# Note and Ask, the project found by its .raea/project, and the world a note is an entity in
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# when a run of an ask's check was (UTC), as raea check stamps its record
|
||||
raea-io-trace = { path = "../../io/trace" }
|
||||
# what each ask has been through, kept as JSON (state.rs)
|
||||
|
||||
@@ -27,7 +27,7 @@ pub(crate) struct New {
|
||||
fn inbox_dir() -> PathBuf {
|
||||
match std::env::var_os("RAEA_INBOX_DIR") {
|
||||
Some(dir) => dir.into(),
|
||||
None => Path::new(&std::env::var_os("HOME").unwrap_or_default()).join(".raea/inbox"),
|
||||
None => raea_io_home::user_home().unwrap_or_default().join(".raea/inbox"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "raea solid info and raea solid view: a solid file run, its parts measured (raea-core-solidinfo), and its review sheets in colour and clay"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-core-solidinfo = { path = "../../core/solidinfo" }
|
||||
# what solid info finds, as raea's one Finding (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
|
||||
@@ -102,7 +102,7 @@ pub fn verb(args: &[String]) -> Option<Result<String, String>> {
|
||||
|
||||
pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
let (Some(verb @ ("info" | "view" | "export")), Some(file)) = (args.get(1).map(String::as_str), args.get(2)) else { return Err(USAGE.into()) };
|
||||
let file = PathBuf::from(file).canonicalize().map_err(|e| format!("{file}: {e}"))?;
|
||||
let file = dunce::canonicalize(&PathBuf::from(file)).map_err(|e| format!("{file}: {e}"))?;
|
||||
let json_out = args.iter().any(|a| a == "--json");
|
||||
let set = flag(args, "--set").map(|s| parse_set(&s)).transpose()?.unwrap_or_default();
|
||||
let expect_path = flag(args, "--expect").map(PathBuf::from).or_else(|| {
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "A render's sound alone (`raea render EDIT.tsx -o OUT.wav`, no frames drawn) and a video's sound written beside it from the same pass (`--audio OUT.wav`)"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-runtime-export = { path = "../../runtime/export" }
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
raea-sys-mix = { path = "../../systems/mix" }
|
||||
|
||||
@@ -42,7 +42,7 @@ pub fn render(args: &[String]) -> Option<R<String>> {
|
||||
/// mastered by its <Mix>, written as 48 kHz WAV, with what it measures.
|
||||
fn sound(args: &[String], out: &Path) -> R<String> {
|
||||
let edit = args.get(1).filter(|a| !a.starts_with('-')).ok_or("raea render EDIT.tsx -o OUT.wav")?;
|
||||
let tsx = PathBuf::from(edit).canonicalize().map_err(|e| format!("{edit}: {e}"))?;
|
||||
let tsx = dunce::canonicalize(&PathBuf::from(edit)).map_err(|e| format!("{edit}: {e}"))?;
|
||||
let dir = tsx.parent().ok_or("the edit has no folder")?.to_path_buf();
|
||||
let js = std::env::temp_dir().join(format!("raea-sound-{}.js", std::process::id()));
|
||||
raea_runtime_bundle::bundle_composition(&tsx, &js, &raea_runtime_bundle::comp_opts(args)?, None)?;
|
||||
|
||||
@@ -6,6 +6,7 @@ license = "FSL-1.1-ALv2"
|
||||
description = "An app's target, web (Blitz on Bevy) or native (Rune), read from its file, and raea app run|check|bundle on either (docs/targets.feature)"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
serde_json = "1"
|
||||
# the page host's frames over BRP
|
||||
base64 = "0.22"
|
||||
|
||||
@@ -97,7 +97,7 @@ mod tests {
|
||||
#[test]
|
||||
fn the_host_runs_as_the_launchers_child() {
|
||||
// canonical, so the launcher's own `pwd` names Resources as this test does (macOS's temp folder is a link)
|
||||
let dir = std::env::temp_dir().canonicalize().unwrap().join(format!("raea-macapp-launcher-{}", std::process::id()));
|
||||
let dir = dunce::canonicalize(&std::env::temp_dir()).unwrap().join(format!("raea-macapp-launcher-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
let (macos, res) = (dir.join("T.app/Contents/MacOS"), dir.join("T.app/Contents/Resources"));
|
||||
std::fs::create_dir_all(&macos).unwrap();
|
||||
|
||||
@@ -71,7 +71,7 @@ pub fn host(args: &[String]) -> Result<String, String> {
|
||||
// the app's folder (relative media and fonts) and the CSS it imported (its @font-face rules), T3d
|
||||
let sheet = script.with_extension("css");
|
||||
std::fs::write(&sheet, css).map_err(|e| format!("{}: {e}", sheet.display()))?;
|
||||
let dir = p.canonicalize().ok().map(raea_io_home::plain).and_then(|c| c.parent().map(Path::to_path_buf)).unwrap_or_default();
|
||||
let dir = dunce::canonicalize(&p).ok().map(raea_io_home::plain).and_then(|c| c.parent().map(Path::to_path_buf)).unwrap_or_default();
|
||||
extra.extend(["--base".to_string(), dir.display().to_string(), "--css".to_string(), sheet.display().to_string()]);
|
||||
} else {
|
||||
handed.push(a.clone());
|
||||
|
||||
@@ -141,7 +141,7 @@ pub fn find(name: &str, built: &[PathBuf]) -> Result<PathBuf, String> {
|
||||
s.push(std::env::consts::EXE_SUFFIX);
|
||||
PathBuf::from(s)
|
||||
};
|
||||
let beside = std::env::current_exe().ok().map(|e| e.canonicalize().unwrap_or(e)).and_then(|e| e.parent().map(|d| d.join(name)));
|
||||
let beside = std::env::current_exe().ok().map(|e| dunce::canonicalize(&e).unwrap_or(e)).and_then(|e| e.parent().map(|d| d.join(name)));
|
||||
let on_path = std::env::var_os("PATH").map(|p| std::env::split_paths(&p).map(|d| d.join(name)).collect::<Vec<_>>()).unwrap_or_default();
|
||||
beside.into_iter().chain(on_path).chain(built.iter().cloned()).map(exe).find(|p| p.is_file()).ok_or(format!("no {name}: put it beside raea or on PATH (in a checkout, build it)"))
|
||||
}
|
||||
@@ -22,7 +22,7 @@ pub struct Built {
|
||||
/// `app` bundled into `dir` (made if missing): app.js and app.css (Tailwind's, for the classes the app's folder uses, after
|
||||
/// any CSS the app imports)
|
||||
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()))?);
|
||||
let app = raea_io_home::plain(dunce::canonicalize(&app).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(), raea_runtime_bundle::inproc::app::WINDOW)?;
|
||||
let folder = app.parent().unwrap_or(Path::new("."));
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "The `raea` verbs that run raea's model tools: sao, tokensynth, setup-audio, sounds, splat, song and gen"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-io-assets = { path = "../../io/assets" }
|
||||
# generation flows: made.app, fal, Replicate, OpenRouter, Modal, ComfyUI (`raea gen`)
|
||||
raea-io-gen = { path = "../../io/gen" }
|
||||
|
||||
@@ -14,7 +14,7 @@ type R<T> = Result<T, String>;
|
||||
|
||||
/// The person's home folder (HOME, or USERPROFILE on Windows).
|
||||
pub fn user_home() -> R<PathBuf> {
|
||||
std::env::var_os("HOME").or_else(|| std::env::var_os("USERPROFILE")).map(PathBuf::from).ok_or_else(|| "no home folder (HOME)".into())
|
||||
raea_io_home::user_home().ok_or_else(|| "no home folder (HOME)".into())
|
||||
}
|
||||
|
||||
/// The JSON file holding `mcpServers` for agents configured that way (Kimi Code, Gemini CLI, Claude Code's own file).
|
||||
|
||||
@@ -187,7 +187,7 @@ pub(crate) fn sounds_get(args: &[String]) -> R<String> {
|
||||
let base = PathBuf::from(flag(args, "--dir").unwrap_or_else(|| ".".into()));
|
||||
let out = flag(args, "-o").map(PathBuf::from).unwrap_or_else(|| base.join("media/sounds").join(format!("{pid}-{iid}")));
|
||||
std::fs::create_dir_all(&out).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
let cache = PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".cache/raea-sounds").join(pid).join(iid);
|
||||
let cache = raea_io_home::user_home().unwrap_or_default().join(".cache/raea-sounds").join(pid).join(iid);
|
||||
let template = pack["url"].as_str().unwrap_or_default();
|
||||
let mut bytes = 0u64;
|
||||
for (file, name, _) in &chosen {
|
||||
|
||||
@@ -71,7 +71,7 @@ pub fn splat(args: &[String]) -> R<String> {
|
||||
|
||||
fn train(args: &[String]) -> R<String> {
|
||||
let (input, params) = parse(args)?;
|
||||
let input = input.canonicalize().map_err(|e| format!("{}: {e}", input.display()))?;
|
||||
let input = dunce::canonicalize(&input).map_err(|e| format!("{}: {e}", input.display()))?;
|
||||
let out = PathBuf::from(flag(args, "-o").or_else(|| flag(args, "--o")).ok_or(format!("-o OUT.ply is required\n{USAGE}"))?);
|
||||
if out.extension().and_then(|e| e.to_str()) != Some("ply") {
|
||||
return Err(format!("-o names a .ply, got {}", out.display()));
|
||||
|
||||
@@ -10,6 +10,7 @@ description = "`raea workspace`, `raea project` and `raea controller`: a workspa
|
||||
dunce = "1"
|
||||
# the controller schema (core/brief controller.rs): a controller file is checked and normalized against it
|
||||
raea-core-brief = { path = "../../core/brief" }
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
serde_json = "1"
|
||||
# a project's compositions, components and controllers read from their source (docs/projects.feature PJ8)
|
||||
raea-app-registry = { path = "registry" }
|
||||
|
||||
@@ -10,6 +10,7 @@ description = "A raea project's compositions, components and controllers, read f
|
||||
dunce = "1"
|
||||
# the version engine/bundle parses TSX with
|
||||
oxc = { version = "=0.152.0", features = ["ast_visit"] }
|
||||
raea-io-home = { path = "../../../io/home" }
|
||||
serde_json = "1"
|
||||
# what the scan finds, as raea's one Finding (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../../core/facts" }
|
||||
@@ -56,7 +56,7 @@ impl Lint {
|
||||
|
||||
/// A path with the home folder as ~, as a person reads it.
|
||||
fn tilde(p: &Path) -> String {
|
||||
match std::env::var_os("HOME").map(PathBuf::from) {
|
||||
match raea_io_home::user_home() {
|
||||
Some(h) if p.starts_with(&h) => format!("~/{}", p.strip_prefix(&h).unwrap_or(p).display()),
|
||||
_ => p.display().to_string(),
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ pub fn root() -> PathBuf {
|
||||
let set = config(None, &["--global", "raea.root"]).ok().filter(|s| !s.is_empty());
|
||||
// HOME, else USERPROFILE: Windows sets no HOME for an app opened from the Start menu, which made the root
|
||||
// Documents/raea under whatever folder raea ran in. git's global config is found the same way.
|
||||
let home = std::env::var_os("HOME").or_else(|| std::env::var_os("USERPROFILE")).map(PathBuf::from).unwrap_or_default();
|
||||
let home = raea_io_home::user_home().unwrap_or_default();
|
||||
match set {
|
||||
Some(s) if s.starts_with("~/") => home.join(&s[2..]),
|
||||
Some(s) => PathBuf::from(s),
|
||||
|
||||
@@ -30,3 +30,6 @@ ignored = ["argh", "accesskit", "rand", "chacha20", "bytemuck", "indexmap", "non
|
||||
[features]
|
||||
default = ["default_font"]
|
||||
default_font = []
|
||||
|
||||
[build-dependencies]
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
@@ -9,7 +9,7 @@ fn main() {
|
||||
let here = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
let src = std::env::var("BEVY_SRC")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|_| PathBuf::from(std::env::var("HOME").unwrap()).join(".cache/raea-vendor/bevy-0.20.0"));
|
||||
.unwrap_or_else(|_| raea_io_home::user_home().unwrap().join(".cache/raea-vendor/bevy-0.20.0"));
|
||||
let out = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
||||
println!("cargo:rerun-if-changed=examples.list");
|
||||
println!("cargo:rerun-if-env-changed=BEVY_SRC");
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "The Blitz-Bevy bridge's bench (run.sh): its examples, each a Bevy program that checks one of the bridge's claims (B3 H1-H11)"
|
||||
|
||||
[dev-dependencies]
|
||||
dunce = "1"
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
raea-runtime-react = { path = "../../runtime/react" }
|
||||
raea-runtime-page = { path = "../../runtime/page" }
|
||||
|
||||
@@ -29,7 +29,7 @@ fn main() {
|
||||
std::process::exit(2);
|
||||
};
|
||||
let out = args.next();
|
||||
let js = PathBuf::from(js).canonicalize().expect("the bundle");
|
||||
let js = dunce::canonicalize(&PathBuf::from(js)).expect("the bundle");
|
||||
let mut app = App::new();
|
||||
app.add_plugins(
|
||||
DefaultPlugins
|
||||
|
||||
@@ -21,7 +21,7 @@ fn main() {
|
||||
eprintln!("usage: entity_ref ENTITY.js");
|
||||
std::process::exit(2);
|
||||
};
|
||||
let js = PathBuf::from(js).canonicalize().expect("the bundle");
|
||||
let js = dunce::canonicalize(&PathBuf::from(js)).expect("the bundle");
|
||||
let (w, h) = (320, 240);
|
||||
let mut app = App::new();
|
||||
app.add_plugins(
|
||||
|
||||
@@ -35,7 +35,7 @@ fn main() {
|
||||
eprintln!("usage: host_query HOSTQUERY.js");
|
||||
std::process::exit(2);
|
||||
};
|
||||
let js = PathBuf::from(js).canonicalize().expect("the bundle");
|
||||
let js = dunce::canonicalize(&PathBuf::from(js)).expect("the bundle");
|
||||
let mut app = App::new();
|
||||
app.add_plugins(
|
||||
DefaultPlugins
|
||||
|
||||
@@ -38,7 +38,7 @@ fn main() {
|
||||
std::process::exit(2);
|
||||
};
|
||||
let n = |i: usize, d: u32| args.get(i).and_then(|a| a.parse().ok()).unwrap_or(d);
|
||||
let a = Args { js: PathBuf::from(js).canonicalize().expect("the bundle"), out: out.clone(), size: (n(2, 640), n(3, 360)), frame: n(4, 30) as i64, fps: n(5, 30) as f64, scene_only };
|
||||
let a = Args { js: dunce::canonicalize(&PathBuf::from(js)).expect("the bundle"), out: out.clone(), size: (n(2, 640), n(3, 360)), frame: n(4, 30) as i64, fps: n(5, 30) as f64, scene_only };
|
||||
if window {
|
||||
std::process::exit(in_window(a));
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ fn main() {
|
||||
eprintln!("usage: shared_state SHARED.js");
|
||||
std::process::exit(2);
|
||||
};
|
||||
let js = PathBuf::from(js).canonicalize().expect("the bundle");
|
||||
let js = dunce::canonicalize(&PathBuf::from(js)).expect("the bundle");
|
||||
let mut app = App::new();
|
||||
app.add_plugins(
|
||||
DefaultPlugins
|
||||
|
||||
@@ -30,7 +30,7 @@ fn main() {
|
||||
std::process::exit(2);
|
||||
};
|
||||
let out = args.next();
|
||||
let js = PathBuf::from(js).canonicalize().expect("the bundle");
|
||||
let js = dunce::canonicalize(&PathBuf::from(js)).expect("the bundle");
|
||||
let mut app = App::new();
|
||||
app.add_plugins(
|
||||
DefaultPlugins
|
||||
|
||||
@@ -13,6 +13,7 @@ description = "A work folder's TypeScript, TSX and their imports bundled in proc
|
||||
crate-type = ["rlib", "cdylib"]
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
serde_json = "1"
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
rolldown = "=1.2.12"
|
||||
|
||||
@@ -30,7 +30,7 @@ impl EditResolve {
|
||||
/// importer was ever under the work folder, so a live game's own `import "react"` went to the engine's React instead of
|
||||
/// the live runtime its tsconfig paths name, and `raea play` threw "not a function" before the first frame
|
||||
pub fn new(e: Edit) -> Self {
|
||||
let real = |p: PathBuf| p.canonicalize().map(raea_io_home::plain).unwrap_or(p);
|
||||
let real = |p: PathBuf| dunce::canonicalize(&p).map(raea_io_home::plain).unwrap_or(p);
|
||||
EditResolve(Edit { dir: real(e.dir), js: real(e.js), work: real(e.work) })
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ impl EditResolve {
|
||||
/// work folder and every live play threw "not a function" (the engine's React, with no `__h`) before its first frame
|
||||
fn from_edit(&self, imp: &str) -> bool {
|
||||
let named = Path::new(imp);
|
||||
let imp = named.canonicalize().map(raea_io_home::plain).unwrap_or_else(|_| named.to_path_buf());
|
||||
let imp = dunce::canonicalize(&named).map(raea_io_home::plain).unwrap_or_else(|_| named.to_path_buf());
|
||||
imp.starts_with(&self.0.work) && !imp.components().any(|c| c.as_os_str() == "node_modules")
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ impl EditResolve {
|
||||
/// not the SDK's copies beside them
|
||||
fn own_source(&self, imp: &str) -> bool {
|
||||
let named = Path::new(imp);
|
||||
let imp = named.canonicalize().map(raea_io_home::plain).unwrap_or_else(|_| named.to_path_buf());
|
||||
let imp = dunce::canonicalize(&named).map(raea_io_home::plain).unwrap_or_else(|_| named.to_path_buf());
|
||||
self.from_edit(&imp.to_string_lossy()) && ["src", "ext"].iter().any(|d| imp.starts_with(self.0.work.join(d)))
|
||||
}
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ impl Plugin for Stamp {
|
||||
}
|
||||
let file = Path::new(path);
|
||||
// the resolver names files with symlinks resolved (/var is /private/var on the Mac)
|
||||
let src = self.src.canonicalize().unwrap_or_else(|_| self.src.clone());
|
||||
let src = dunce::canonicalize(&self.src).unwrap_or_else(|_| self.src.clone());
|
||||
let Some(rel) = stamp::own(file, &src).or_else(|| stamp::own(file, &self.src)) else { return Ok(None) };
|
||||
let text = std::fs::read_to_string(file)?;
|
||||
let Some(stamped) = stamp::stamp(&text, &rel, jsx, &self.helper.to_string_lossy()) else { return Ok(None) };
|
||||
|
||||
@@ -20,6 +20,7 @@ path = "src/bin/raea-bevy-sdk.rs"
|
||||
required-features = ["bevy-plugins"]
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-runtime-plugins = { path = "../../runtime/plugins" }
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# the schemas of what an agent writes (brief.ts, script.ts, taste.ts, controllers): raea context reads specs against them
|
||||
|
||||
@@ -111,7 +111,7 @@ fn notes_run(project: &Path, rules: &[raea_app_notes::check::Rule], args: &[Stri
|
||||
/// worlds, print). The script's default export, if a function, is called; what it prints goes to stdout; a throw
|
||||
/// ends the run with exit 1.
|
||||
pub fn run_script(args: &[String]) -> R<i32> {
|
||||
let ts = PathBuf::from(&args[1]).canonicalize().map_err(|e| format!("{}: {e}", args[1]))?;
|
||||
let ts = dunce::canonicalize(&PathBuf::from(&args[1])).map_err(|e| format!("{}: {e}", args[1]))?;
|
||||
let out = std::env::temp_dir().join(format!("raea-cli-{}.js", std::process::id()));
|
||||
bundle_script(&ts, &out)?;
|
||||
let secs: f64 = flag(args, "--timeout").and_then(|t| t.parse().ok()).unwrap_or(120.0);
|
||||
@@ -277,7 +277,7 @@ pub fn run(args: &[String]) -> R<String> {
|
||||
.to_string());
|
||||
}
|
||||
if args.first().map(String::as_str) == Some("bundle") && args.len() >= 2 {
|
||||
let ts = PathBuf::from(&args[1]).canonicalize().map_err(|e| format!("{}: {e}", args[1]))?;
|
||||
let ts = dunce::canonicalize(&PathBuf::from(&args[1])).map_err(|e| format!("{}: {e}", args[1]))?;
|
||||
let out = PathBuf::from(flag(args, "-o").ok_or("raea bundle SCRIPT.ts -o OUT.js")?);
|
||||
if args.iter().any(|a| a == "--composition-bundle") {
|
||||
let portable = flag(args, "--portable").map(PathBuf::from);
|
||||
@@ -319,7 +319,7 @@ pub fn run(args: &[String]) -> R<String> {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
files.push(PathBuf::from(&args[i]).canonicalize().map_err(|e| format!("{}: {e}", args[i]))?);
|
||||
files.push(dunce::canonicalize(&PathBuf::from(&args[i])).map_err(|e| format!("{}: {e}", args[i]))?);
|
||||
i += 1;
|
||||
}
|
||||
let extra: Vec<&str> = owned.iter().map(String::as_str).collect();
|
||||
@@ -331,7 +331,7 @@ pub fn run(args: &[String]) -> R<String> {
|
||||
}
|
||||
// the repo root for fixtures (tests read RAEA_ROOT through host.env)
|
||||
if std::env::var_os("RAEA_ROOT").is_none() {
|
||||
unsafe { std::env::set_var("RAEA_ROOT", raea_io_home::home().canonicalize().unwrap_or_default()) };
|
||||
unsafe { std::env::set_var("RAEA_ROOT", dunce::canonicalize(&raea_io_home::home()).unwrap_or_default()) };
|
||||
}
|
||||
let out = std::env::temp_dir().join(format!("raea-cli-t{}.js", std::process::id()));
|
||||
bundle_tests(&files, &out, flag(args, "--filter").as_deref(), &extra)?;
|
||||
|
||||
@@ -91,7 +91,7 @@ fn brief_at(project: &str) -> R<PathBuf> {
|
||||
let path = Path::new(project);
|
||||
let brief_path = if path.is_dir() {
|
||||
// from anywhere inside a project: the nearest folder up with a brief.ts or a .raea/project
|
||||
let dir = path.canonicalize().ok().and_then(|d| d.ancestors().find(|a| a.join("brief.ts").is_file() || a.join(".raea/project").is_file()).map(Path::to_path_buf));
|
||||
let dir = dunce::canonicalize(&path).ok().and_then(|d| d.ancestors().find(|a| a.join("brief.ts").is_file() || a.join(".raea/project").is_file()).map(Path::to_path_buf));
|
||||
dir.unwrap_or_else(|| path.to_path_buf()).join("brief.ts")
|
||||
} else {
|
||||
path.to_path_buf()
|
||||
|
||||
@@ -14,7 +14,7 @@ fn source_of(args: &[String]) -> Option<PathBuf> {
|
||||
}
|
||||
let f = Path::new(args.get(1)?);
|
||||
let ext = f.extension()?.to_str()?;
|
||||
(matches!(ext, "tsx" | "ts" | "jsx" | "js") && f.is_file()).then(|| f.canonicalize().unwrap_or_else(|_| f.to_path_buf()))
|
||||
(matches!(ext, "tsx" | "ts" | "jsx" | "js") && f.is_file()).then(|| dunce::canonicalize(&f).unwrap_or_else(|_| f.to_path_buf()))
|
||||
}
|
||||
|
||||
/// raea's caches' refused/HASH.json (raea_io_home::caches) for that file (RAEA_REFUSED_CACHE moves it; "0" turns it off)
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::sync::atomic::Ordering;
|
||||
|
||||
/// The default export of a spec module, as the JSON it evaluates to.
|
||||
pub fn spec_json(ts: &Path) -> R<String> {
|
||||
let ts = ts.canonicalize().map_err(|e| format!("{}: {e}", ts.display()))?;
|
||||
let ts = dunce::canonicalize(&ts).map_err(|e| format!("{}: {e}", ts.display()))?;
|
||||
let out = std::env::temp_dir().join(format!("raea-spec-{}.js", std::process::id()));
|
||||
bundle_module(&ts, &out, PRINT_DEFAULT)?;
|
||||
// the JSON is ours to read, not the person's to see: the run prints nothing to the terminal
|
||||
|
||||
@@ -8,3 +8,4 @@ description = "The agent's TypeScript and TSX loaded in process: resolved inside
|
||||
|
||||
[dependencies]
|
||||
deno_ast = { version = "=0.53.3", features = ["transpiling"] }
|
||||
dunce = "1"
|
||||
@@ -126,7 +126,7 @@ fn lexical(p: &Path) -> PathBuf {
|
||||
impl Loader {
|
||||
/// `root` is the space folder; `prebuilt` the libraries the prebuilt bundle serves.
|
||||
pub fn new(root: &Path, prebuilt: Vec<Prebuilt>) -> Result<Loader, Refusal> {
|
||||
let root = root.canonicalize().map_err(|e| Refusal::new(RefusalKind::Space, format!("the space {} can't be opened: {e}", root.display()), None, None))?;
|
||||
let root = dunce::canonicalize(&root).map_err(|e| Refusal::new(RefusalKind::Space, format!("the space {} can't be opened: {e}", root.display()), None, None))?;
|
||||
Ok(Loader { root, prebuilt: prebuilt.into_iter().map(|p| (p.specifier.clone(), p)).collect(), cache: HashMap::new(), transpiled: 0 })
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ impl Loader {
|
||||
// the importing file's folder by its real path (macOS's /var is /private/var; spaces link folders in), and the
|
||||
// import joined to it without following links, so a linked media/ inside the space stays inside it
|
||||
let base = if referrer.starts_with("raea:") { self.root.clone() } else { Path::new(from).parent().map(Path::to_path_buf).unwrap_or_else(|| self.root.clone()) };
|
||||
let base = base.canonicalize().unwrap_or(base);
|
||||
let base = dunce::canonicalize(&base).unwrap_or(base);
|
||||
let raw = specifier.strip_prefix("file://").unwrap_or(specifier);
|
||||
let want = lexical(&if raw.starts_with('/') { PathBuf::from(raw) } else { base.join(raw) });
|
||||
// inside the space, or inside its workspace's shared/ (a file there imports its neighbours relatively)
|
||||
|
||||
@@ -38,8 +38,8 @@ fn imports_resolve_inside_the_space_and_refuse_outside() {
|
||||
let d = space("resolve", &[("edit.tsx", ""), ("parts/index.ts", "export const x = 1;"), ("a/b.ts", "")]);
|
||||
let l = Loader::new(&d, libs()).unwrap();
|
||||
let entry = d.join("edit.tsx").display().to_string();
|
||||
assert_eq!(l.resolve("./parts", &entry).unwrap(), ModuleId::File(d.canonicalize().unwrap().join("parts/index.ts")));
|
||||
let b = d.canonicalize().unwrap().join("a/b.ts").display().to_string();
|
||||
assert_eq!(l.resolve("./parts", &entry).unwrap(), ModuleId::File(dunce::canonicalize(&d).unwrap().join("parts/index.ts")));
|
||||
let b = dunce::canonicalize(&d).unwrap().join("a/b.ts").display().to_string();
|
||||
assert!(matches!(l.resolve("../edit", &b).unwrap(), ModuleId::File(_)));
|
||||
let out = l.resolve("../../etc/passwd", &entry).unwrap_err().message;
|
||||
assert!(out.contains("outside the space"), "{out}");
|
||||
@@ -103,7 +103,7 @@ fn shared_imports_resolve_to_the_workspaces_shared_folder() {
|
||||
("shared/components/props/index.ts", "export const p = 1;"),
|
||||
("projects/a/compositions/main.tsx", ""),
|
||||
]);
|
||||
let root = w.canonicalize().unwrap();
|
||||
let root = dunce::canonicalize(&w).unwrap();
|
||||
let l = Loader::new(&w.join("projects/a"), libs()).unwrap();
|
||||
let entry = root.join("projects/a/compositions/main.tsx").display().to_string();
|
||||
assert_eq!(l.resolve("@shared/components/desk", &entry).unwrap(), ModuleId::File(root.join("shared/components/desk.tsx")));
|
||||
|
||||
@@ -18,7 +18,9 @@ modules = ["dep:raea-modules"]
|
||||
portable = ["raea-runtime-jsengine/portable"]
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-core-calls = { path = "../../core/calls" }
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# the shell's natives (fs, net, sql, archive)
|
||||
raea-io-shell = { path = "../../io/shell", default-features = false }
|
||||
serde_json = "1"
|
||||
|
||||
@@ -324,7 +324,7 @@ pub fn call(op: &str, a: &[Value]) -> Value {
|
||||
}
|
||||
"rename" => std::fs::rename(s(0), s(1)).map(|_| Value::Null).unwrap_or_else(|e| io_err(e, "rename", &s(0))),
|
||||
"copyFile" => std::fs::copy(s(0), s(1)).map(|_| Value::Null).unwrap_or_else(|e| io_err(e, "copyfile", &s(0))),
|
||||
"realpath" => std::fs::canonicalize(s(0)).map(|p| json!(p.display().to_string())).unwrap_or_else(|e| io_err(e, "realpath", &s(0))),
|
||||
"realpath" => dunce::canonicalize(s(0)).map(|p| json!(p.display().to_string())).unwrap_or_else(|e| io_err(e, "realpath", &s(0))),
|
||||
"mkdtemp" => {
|
||||
let prefix = s(0);
|
||||
for _ in 0..100 {
|
||||
@@ -359,7 +359,7 @@ pub fn call(op: &str, a: &[Value]) -> Value {
|
||||
}
|
||||
"spawn" => spawn(&s(0), a.get(1), a.get(2).unwrap_or(&Value::Null)),
|
||||
"tmpdir" => json!(std::env::temp_dir().display().to_string().trim_end_matches('/')),
|
||||
"homedir" => json!(std::env::var("HOME").unwrap_or_default()),
|
||||
"homedir" => json!(raea_io_home::user_home().unwrap_or_default().display().to_string()),
|
||||
"cwd" => json!(std::env::current_dir().map(|p| p.display().to_string()).unwrap_or_default()),
|
||||
"resolve" => resolve_file(&s(0), Path::new(&s(1)), false).map(|p| json!(p.display().to_string())).unwrap_or_else(|e| err("MODULE_NOT_FOUND", e)),
|
||||
// a CommonJS file's source for require (JSON as an expression, TypeScript transpiled to CommonJS)
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "HTML, CSS and React pages in Bevy (docs/blitz-bevy.feature): Blitz works out what a page looks like, Vello paints it on Bevy's own GPU device into a Bevy Image"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
# the layers under it
|
||||
raea-sys-page = { path = "../../systems/page" }
|
||||
raea-sys-fonts = { path = "../../systems/fonts" }
|
||||
|
||||
@@ -217,7 +217,7 @@ impl BlitzPage {
|
||||
let at = Page { size: UVec2::new(self.w, self.h), scale: 1.0 };
|
||||
let mut config = raea_sys_page::config(at);
|
||||
config.net_provider = Some(Arc::new(raea_sys_page::net::FileNet { roots: root.map(Path::to_path_buf).into_iter().collect() }));
|
||||
let abs = std::fs::canonicalize(path).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
let abs = dunce::canonicalize(path).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
config.base_url = Some(url::Url::from_file_path(&abs).map_err(|_| format!("{}: not a file URL", abs.display()))?.to_string());
|
||||
config.font_ctx = self.fonts.clone();
|
||||
// a byte order mark is the decoder's, never the document's (it also hid `<?xml` from Blitz's sniffing); the
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "Made assets: a composition's make(model, prompt, seed, params) kept once under its content hash, from the local models (SAO, TokenSynth, splats, matchmove)"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-io-home = { path = "../home" }
|
||||
serde_json = "1"
|
||||
sha2 = "0.10"
|
||||
|
||||
@@ -173,7 +173,7 @@ fn canonical(j: &J, whole: bool) -> J {
|
||||
pub fn install_dir(model: &str) -> PathBuf {
|
||||
let (var, name) = install_var(model);
|
||||
std::env::var_os(var).filter(|v| !v.is_empty()).map(PathBuf::from)
|
||||
.unwrap_or_else(|| PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".cache").join(name))
|
||||
.unwrap_or_else(|| raea_io_home::user_home().unwrap_or_default().join(".cache").join(name))
|
||||
}
|
||||
|
||||
/// A local model's install variable and default folder name.
|
||||
@@ -189,7 +189,7 @@ fn install_var(model: &str) -> (&'static str, &'static str) {
|
||||
pub fn setup_script(model: &str) -> PathBuf {
|
||||
let tools = std::env::var_os("RAEA_TOOLS").map(PathBuf::from).unwrap_or_else(|| raea_io_home::home().join("tools"));
|
||||
let p = tools.join(model).join("setup.sh");
|
||||
p.canonicalize().unwrap_or(p)
|
||||
dunce::canonicalize(&p).unwrap_or(p)
|
||||
}
|
||||
|
||||
/// Whether a local model can run from `dir`. SAO: the venv and either run.py with setup.sh's `.ready`, or the
|
||||
@@ -270,7 +270,7 @@ pub fn matchmove_params(p: &J) -> Result<J, String> {
|
||||
pub fn perceive_bin() -> PathBuf {
|
||||
// raea-perceive.exe on Windows (#43)
|
||||
const NAME: &str = if cfg!(windows) { "raea-perceive.exe" } else { "raea-perceive" };
|
||||
let beside = std::env::current_exe().ok().and_then(|e| e.canonicalize().ok()).and_then(|e| Some(e.parent()?.join(NAME)));
|
||||
let beside = std::env::current_exe().ok().and_then(|e| dunce::canonicalize(&e).ok()).and_then(|e| Some(e.parent()?.join(NAME)));
|
||||
let found = beside.into_iter().chain([PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR"), "/../../target/release")).join(NAME)]).chain(std::env::var_os("PATH").iter().flat_map(std::env::split_paths).map(|d| d.join(NAME))).find(|p| p.is_file());
|
||||
std::env::var_os("RAEA_PERCEIVE").filter(|v| !v.is_empty()).map(PathBuf::from).or(found).unwrap_or_else(|| NAME.into())
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ use super::*;
|
||||
|
||||
/// Where the splat trainer is installed: $RAEA_SPLAT, else ~/.cache/raea-splat.
|
||||
pub fn splat_dir() -> PathBuf {
|
||||
std::env::var_os("RAEA_SPLAT").filter(|v| !v.is_empty()).map(PathBuf::from)
|
||||
.unwrap_or_else(|| PathBuf::from(std::env::var("HOME").unwrap_or_default()).join(".cache/raea-splat"))
|
||||
raea_io_home::env_path("RAEA_SPLAT", ".cache/raea-splat")
|
||||
}
|
||||
|
||||
fn splat_installed(dir: &Path) -> bool {
|
||||
|
||||
@@ -7,4 +7,5 @@ publish = false
|
||||
description = "A CapCut desktop draft written from a timeline of clips (docs/capcut.feature CC2): tracks, segments and materials as CapCut's own, the project folder, the store's version markers and its project list"
|
||||
|
||||
[dependencies]
|
||||
raea-io-home = { path = "../home" }
|
||||
serde_json = "1"
|
||||
@@ -14,7 +14,7 @@ pub fn store_root() -> Option<PathBuf> {
|
||||
let local = std::env::var_os("LOCALAPPDATA")?;
|
||||
return Some(PathBuf::from(local).join("CapCut/User Data/Projects/com.lveditor.draft"));
|
||||
}
|
||||
let home = std::env::var_os("HOME")?;
|
||||
let home = raea_io_home::user_home()?;
|
||||
cfg!(target_os = "macos").then(|| PathBuf::from(home).join("Movies/CapCut/User Data/Projects/com.lveditor.draft"))
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ pub fn available() -> bool {
|
||||
}
|
||||
|
||||
fn home_dir() -> PathBuf {
|
||||
std::env::var_os("HOME").map(PathBuf::from).unwrap_or_default()
|
||||
raea_io_home::user_home().unwrap_or_default()
|
||||
}
|
||||
|
||||
fn command() -> Command {
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "Generation flows: made.app's models at provider cost, ComfyUI workflows read and written, and the runner that routes each step to made, fal, Replicate, OpenRouter, Modal, a ComfyUI server or a local model"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-io-gen-comfy = { path = "../gen-comfy" }
|
||||
raea-io-gen-core = { path = "../gen-core" }
|
||||
raea-io-home = { path = "../home" }
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ pub fn command(args: &[String], local: Option<&dyn Local>) -> Result<String, Str
|
||||
let images: Vec<&str> = args.windows(2).filter(|w| w[0] == "--image").map(|w| w[1].as_str()).collect();
|
||||
let mut flow = Flow::default();
|
||||
for (k, f) in images.iter().enumerate() {
|
||||
let abs = std::fs::canonicalize(f).map_err(|e| format!("{f}: {e}"))?;
|
||||
let abs = dunce::canonicalize(f).map_err(|e| format!("{f}: {e}"))?;
|
||||
flow.steps.insert(format!("in{k}"), Step::new("media.load", json!({"path": abs})));
|
||||
}
|
||||
let refs: Vec<J> = (0..images.len()).map(|k| json!(format!("@in{k}"))).collect();
|
||||
|
||||
+1
-1
@@ -398,7 +398,7 @@ fn name_output(dir: &Path, name: &str, files: &[PathBuf]) -> Result<Vec<PathBuf>
|
||||
let copy = |from: &Path, to: &Path| {
|
||||
// a name that already is the file (a link to it, or the file itself) is left alone: copying a file onto itself
|
||||
// truncates it to nothing (11-05: four Tripo models lost their step files so). A link elsewhere is replaced.
|
||||
if let (Ok(a), Ok(b)) = (std::fs::canonicalize(from), std::fs::canonicalize(to)) {
|
||||
if let (Ok(a), Ok(b)) = (dunce::canonicalize(from), dunce::canonicalize(to)) {
|
||||
if a == b {
|
||||
return Ok(to.to_path_buf());
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "Where raea's own files are ($RAEA_HOME, an install's share/raea, or the tree a build came from), and its per-user caches and logs"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
serde_json = "1"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
+36
-7
@@ -13,7 +13,7 @@ pub fn home() -> std::path::PathBuf {
|
||||
if let Some(h) = std::env::var_os("RAEA_HOME").filter(|v| !v.is_empty()) {
|
||||
return std::path::PathBuf::from(h);
|
||||
}
|
||||
let installed = std::env::current_exe().ok().and_then(|e| e.canonicalize().ok()).map(plain).and_then(|e| e.parent()?.parent().map(|p| p.join("share/raea")));
|
||||
let installed = std::env::current_exe().ok().and_then(|e| dunce::canonicalize(&e).ok()).map(plain).and_then(|e| e.parent()?.parent().map(|p| p.join("share/raea")));
|
||||
if let Some(d) = installed.filter(|d| d.join("sdk/raea/src").is_dir()) {
|
||||
return d;
|
||||
}
|
||||
@@ -22,7 +22,7 @@ pub fn home() -> std::path::PathBuf {
|
||||
return std::path::PathBuf::from("/nonexistent/raea");
|
||||
}
|
||||
let tree = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
|
||||
tree.canonicalize().map(plain).unwrap_or(tree)
|
||||
dunce::canonicalize(&tree).map(plain).unwrap_or(tree)
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
@@ -38,11 +38,25 @@ pub fn plain(p: std::path::PathBuf) -> std::path::PathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
/// `p` canonical (links resolved, and on Windows plain C:\..., through dunce), or `p` as given when it can't be read
|
||||
/// (it doesn't exist yet).
|
||||
pub fn real(p: std::path::PathBuf) -> std::path::PathBuf {
|
||||
dunce::canonicalize(&p).unwrap_or(p)
|
||||
}
|
||||
|
||||
/// a verbatim drive path's plain form (`\\?\C:\x` is `C:\x`); None for any other path
|
||||
fn drive(s: &str) -> Option<&str> {
|
||||
s.strip_prefix(r"\\?\").filter(|r| r.as_bytes().get(1) == Some(&b':'))
|
||||
}
|
||||
|
||||
/// The person's home folder: $HOME, else %USERPROFILE%, the order Git for Windows reads them in. Windows gives an app
|
||||
/// opened from the Start menu or Explorer no HOME, so a read of HOME alone found nothing there and put ~/.raea, the
|
||||
/// caches and the inbox under whatever folder raea ran in. None when neither is set (an empty one counts as unset).
|
||||
/// Every read of the home folder goes through here (tools/windows-paths.sh).
|
||||
pub fn user_home() -> Option<std::path::PathBuf> {
|
||||
["HOME", "USERPROFILE"].into_iter().find_map(|k| std::env::var_os(k).filter(|v| !v.is_empty())).map(std::path::PathBuf::from)
|
||||
}
|
||||
|
||||
/// Where raea's models are kept (Beat This!, Demucs, TransNet, Silero, the Core ML ones): ~/.local/share/raea-models on
|
||||
/// the Mac and Linux, %LOCALAPPDATA%\raea\models on Windows, which has no HOME (#43). Relative when neither is set.
|
||||
pub fn models() -> std::path::PathBuf {
|
||||
@@ -50,7 +64,7 @@ pub fn models() -> std::path::PathBuf {
|
||||
let var = |k: &str| std::env::var_os(k).filter(|v| !v.is_empty()).map(PathBuf::from);
|
||||
match var("LOCALAPPDATA").filter(|_| cfg!(windows)) {
|
||||
Some(d) => d.join("raea").join("models"),
|
||||
None => var("HOME").unwrap_or_default().join(".local/share/raea-models"),
|
||||
None => user_home().unwrap_or_default().join(".local/share/raea-models"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +87,7 @@ fn user_dir(apple: &str, xdg: &str, xdg_default: &str, windows: &str) -> Option<
|
||||
if cfg!(windows) {
|
||||
return std::env::var_os("LOCALAPPDATA").filter(|d| !d.is_empty()).map(|d| PathBuf::from(d).join("raea").join(windows));
|
||||
}
|
||||
let home = PathBuf::from(std::env::var_os("HOME").filter(|h| !h.is_empty())?);
|
||||
let home = user_home()?;
|
||||
if cfg!(target_vendor = "apple") {
|
||||
return Some(home.join(apple));
|
||||
}
|
||||
@@ -86,7 +100,7 @@ fn user_dir(apple: &str, xdg: &str, xdg_default: &str, windows: &str) -> Option<
|
||||
pub fn env_path(var: &str, under_home: &str) -> std::path::PathBuf {
|
||||
match std::env::var_os(var).filter(|v| !v.is_empty()) {
|
||||
Some(p) => p.into(),
|
||||
None => std::path::PathBuf::from(std::env::var_os("HOME").unwrap_or_default()).join(under_home),
|
||||
None => user_home().unwrap_or_default().join(under_home),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +197,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn caches_and_logs_follow_the_platform() {
|
||||
fn caches_logs_and_the_home_folder_follow_the_platform() {
|
||||
// one test, so nothing else reads these variables while it sets them
|
||||
unsafe {
|
||||
std::env::set_var("HOME", "/h");
|
||||
@@ -197,6 +211,21 @@ mod tests {
|
||||
// a relative XDG_CACHE_HOME is ignored, as the spec says
|
||||
assert_eq!((c.to_str().unwrap(), l.to_str().unwrap()), ("/h/.cache/raea", "/state/raea"));
|
||||
}
|
||||
// the home folder: HOME, else USERPROFILE (an app opened from Windows' Start menu has no HOME); empty is unset
|
||||
let was = std::env::var_os("USERPROFILE");
|
||||
unsafe { std::env::set_var("USERPROFILE", r"C:\Users\Ada") };
|
||||
assert_eq!(super::user_home().unwrap().to_str(), Some("/h"));
|
||||
unsafe { std::env::set_var("HOME", "") };
|
||||
assert_eq!(super::user_home().unwrap().to_str(), Some(r"C:\Users\Ada"));
|
||||
assert_eq!(super::env_path("RAEA_NO_SUCH_VAR", ".raea/env"), std::path::Path::new(r"C:\Users\Ada").join(".raea/env"));
|
||||
unsafe { std::env::remove_var("USERPROFILE") };
|
||||
assert_eq!(super::user_home(), None);
|
||||
unsafe {
|
||||
std::env::set_var("HOME", "/h");
|
||||
if let Some(w) = was {
|
||||
std::env::set_var("USERPROFILE", w);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +238,7 @@ pub fn offline(what: &str) -> Result<(), String> {
|
||||
let set = match std::env::var("RAEA_OFFLINE") {
|
||||
Ok(v) => on(&v),
|
||||
Err(_) => {
|
||||
let file = std::env::var_os("RAEA_ENV_FILE").map(std::path::PathBuf::from).or_else(|| std::env::var_os("HOME").map(|h| std::path::PathBuf::from(h).join(".raea/env")));
|
||||
let file = std::env::var_os("RAEA_ENV_FILE").map(std::path::PathBuf::from).or_else(|| user_home().map(|h| h.join(".raea/env")));
|
||||
file.and_then(|f| std::fs::read_to_string(f).ok()).is_some_and(|s| {
|
||||
s.lines().filter(|l| !l.trim_start().starts_with('#')).filter_map(|l| l.split_once('=')).any(|(k, v)| k.trim() == "RAEA_OFFLINE" && on(v.trim().trim_matches('"')))
|
||||
})
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ use super::*;
|
||||
|
||||
/// Where raea's npm keeps what it fetched: RAEA_NPM_HOME, or ~/.raea/npm.
|
||||
pub(crate) fn home() -> PathBuf {
|
||||
std::env::var_os("RAEA_NPM_HOME").map(PathBuf::from).unwrap_or_else(|| PathBuf::from(std::env::var_os("HOME").unwrap_or_default()).join(".raea/npm"))
|
||||
raea_io_home::env_path("RAEA_NPM_HOME", ".raea/npm")
|
||||
}
|
||||
|
||||
/// A package name as one path segment ("@scope/name" is "@scope+name").
|
||||
|
||||
@@ -12,6 +12,7 @@ default = ["net"]
|
||||
net = ["dep:raea-io-net", "dep:url"]
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
raea-core-calls = { path = "../../core/calls" }
|
||||
serde_json = "1"
|
||||
|
||||
@@ -41,7 +41,7 @@ fn inside(root: &Path, base: &Path, rel: &Path) -> Option<PathBuf> {
|
||||
}
|
||||
|
||||
fn run(v: &Value) -> R<Value> {
|
||||
let root = PathBuf::from(s(v, "root")?).canonicalize().map_err(|e| e.to_string())?;
|
||||
let root = dunce::canonicalize(&PathBuf::from(s(v, "root")?)).map_err(|e| e.to_string())?;
|
||||
let cwd = PathBuf::from(s(v, "cwd")?);
|
||||
let file = inside(&root, &cwd, Path::new(s(v, "file")?)).ok_or("tar: the archive is outside the project")?;
|
||||
let gz = v.get("gzip").and_then(Value::as_bool).unwrap_or(false) || s(v, "file").map(|f| f.ends_with(".tgz") || f.ends_with(".gz")).unwrap_or(false);
|
||||
|
||||
@@ -13,7 +13,7 @@ pub(crate) fn calls() -> Vec<raea_core_calls::Call> {
|
||||
mk("fs.open", "{ root: string }", "{ id: number; root: string }", "a project folder opened as a filesystem (made if missing)", Arc::new(|v| {
|
||||
let root = Path::new(s(v, "root")?);
|
||||
fs::create_dir_all(root).map_err(|e| format!("{}: {e}", root.display()))?;
|
||||
let root = root.canonicalize().map_err(|e| e.to_string())?;
|
||||
let root = dunce::canonicalize(&root).map_err(|e| e.to_string())?;
|
||||
let mut pr = Project { root: root.clone(), group: None, seq: 0, state: "0".repeat(64), done: Vec::new(), redo: Vec::new() };
|
||||
for r in pr.rows() {
|
||||
pr.seq = r["seq"].as_u64().unwrap_or(pr.seq);
|
||||
|
||||
@@ -110,7 +110,7 @@ impl Project {
|
||||
/// The real path with every link followed, refused if it leaves the project.
|
||||
fn follow(&self, v: &str, op: &str) -> R<PathBuf> {
|
||||
let p = self.real(v)?;
|
||||
match p.canonicalize() {
|
||||
match dunce::canonicalize(&p) {
|
||||
Ok(c) if c.starts_with(&self.root) => {
|
||||
if c.strip_prefix(&self.root).ok().and_then(|r| r.components().next()).is_some_and(|c| c.as_os_str() == META) {
|
||||
return Err(err("ENOENT", "no such file or directory", op, v));
|
||||
@@ -128,7 +128,7 @@ impl Project {
|
||||
/// put in reach.
|
||||
fn follow_read(&self, v: &str, op: &str) -> R<PathBuf> {
|
||||
match self.follow(v, op) {
|
||||
Err(e) if e.starts_with("EACCES") => self.real(v)?.canonicalize().map_err(|_| err("ENOENT", "no such file or directory", op, v)),
|
||||
Err(e) if e.starts_with("EACCES") => dunce::canonicalize(&self.real(v)?).map_err(|_| err("ENOENT", "no such file or directory", op, v)),
|
||||
r => r,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ pub(crate) fn install_signal_handlers() {
|
||||
|
||||
/// Sessions under `base` that ended unclean (no end.json, their process gone) get macOS's crash report for their pid.
|
||||
pub(crate) fn adopt_crash_reports(base: &Path) {
|
||||
let reports = std::env::var_os("HOME").map(|h| PathBuf::from(h).join("Library/Logs/DiagnosticReports"));
|
||||
let reports = raea_io_home::user_home().map(|h| h.join("Library/Logs/DiagnosticReports"));
|
||||
let Ok(entries) = std::fs::read_dir(base) else { return };
|
||||
for e in entries.flatten() {
|
||||
let d = e.path();
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "raea-bundle's library (engine/bundle: Rolldown) loaded at run time: an entry in, its script and CSS out"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
# never a Cargo dependency on raea-bundle itself: Rolldown's crates turn on serde_json's preserve_order and
|
||||
# arbitrary_precision, and features unify across a binary (f60e0b7)
|
||||
libloading = "0.8"
|
||||
|
||||
@@ -49,9 +49,9 @@ pub const SCREEN: &str = "{ width: innerWidth, height: innerHeight }";
|
||||
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()))?);
|
||||
let app = raea_io_home::plain(dunce::canonicalize(&app).map_err(|e| format!("{}: {e}", app.display()))?);
|
||||
// one path per file: a module reached by two spellings of its path is bundled twice (two wires, two call ids)
|
||||
let home = &raea_io_home::plain(home.canonicalize().map_err(|e| format!("{}: {e}", home.display()))?);
|
||||
let home = &raea_io_home::plain(dunce::canonicalize(&home).map_err(|e| format!("{}: {e}", home.display()))?);
|
||||
// one work folder per call: tests bundle on several threads of one process
|
||||
static N: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
|
||||
let work = std::env::temp_dir().join(format!("raea-app-{}-{}", std::process::id(), N.fetch_add(1, std::sync::atomic::Ordering::Relaxed)));
|
||||
|
||||
@@ -24,7 +24,7 @@ pub fn lib() -> Result<&'static Lib, String> {
|
||||
let mut at: Vec<PathBuf> = std::env::var_os("RAEA_BUNDLE_LIB").map(PathBuf::from).into_iter().collect();
|
||||
// beside the binary (runtime/react/build.rs puts it there), or a folder up (test binaries run from deps/); the binary
|
||||
// itself, not a link to it (an install links ~/.local/bin/raea to ~/.raea/bin)
|
||||
if let Some(dir) = std::env::current_exe().ok().map(|e| e.canonicalize().unwrap_or(e)).and_then(|e| e.parent().map(Path::to_path_buf)) {
|
||||
if let Some(dir) = std::env::current_exe().ok().map(raea_io_home::real).and_then(|e| e.parent().map(Path::to_path_buf)) {
|
||||
at.push(dir.join(&name));
|
||||
at.extend(dir.parent().map(|d| d.join(&name)));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ fn dir() -> Option<PathBuf> {
|
||||
return None;
|
||||
}
|
||||
// unset: ~/.raea/renders, the home being USERPROFILE on Windows, which has no HOME
|
||||
match (named, std::env::var_os("HOME").or(std::env::var_os("USERPROFILE"))) {
|
||||
match (named, raea_io_home::user_home()) {
|
||||
(Some(d), _) => Some(PathBuf::from(d)),
|
||||
(None, Some(home)) => Some(Path::new(&home).join(".raea/renders")),
|
||||
(None, None) => None,
|
||||
|
||||
@@ -19,6 +19,7 @@ media = ["dep:raea-io-media", "dep:cpal"]
|
||||
[dependencies]
|
||||
# images
|
||||
bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "bevy_render", "bevy_image"] }
|
||||
dunce = "1"
|
||||
# the op wire to and from a page's script
|
||||
raea-core-wire = { path = "../../core/wire" }
|
||||
raea-io-net = { path = "../../io/net", features = ["ws"] }
|
||||
|
||||
@@ -134,11 +134,11 @@ pub fn prepare(file: &Path, fps: f64, fonts: Option<&Path>, size: Option<(u32, u
|
||||
let file = if file.is_dir() { file.join("index.html") } else { file.to_path_buf() };
|
||||
let source = std::fs::read_to_string(&file).map_err(|e| format!("{}: {e}", file.display()))?;
|
||||
// (plain: Windows canonicalizes to a verbatim `\\?\D:\` path, #40)
|
||||
let file = file.canonicalize().map(raea_io_home::plain).unwrap_or(file);
|
||||
let file = dunce::canonicalize(&file).map(raea_io_home::plain).unwrap_or(file);
|
||||
// served: the page's folder is `root` and the page a path under it (`/x` is then root's x, as a server rooted
|
||||
// there serves it); the project listing is left out (a WPT checkout is too big to list, and only a
|
||||
// composition's sub-compositions use it)
|
||||
let served = root.and_then(|r| r.canonicalize().ok()).map(raea_io_home::plain).filter(|r| file.starts_with(r));
|
||||
let served = root.and_then(|r| dunce::canonicalize(&r).ok()).map(raea_io_home::plain).filter(|r| file.starts_with(r));
|
||||
let (dir, name, files) = match &served {
|
||||
Some(r) => (r.clone(), file.strip_prefix(r).unwrap_or(&file).to_string_lossy().into_owned(), vec![]),
|
||||
None => {
|
||||
|
||||
@@ -14,6 +14,7 @@ name = "raea_runtime_jsengine"
|
||||
portable = ["dep:rquickjs"]
|
||||
|
||||
[dependencies]
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
rquickjs = { version = "0.14", optional = true, features = ["loader"] }
|
||||
|
||||
[target.'cfg(target_vendor = "apple")'.dependencies]
|
||||
|
||||
@@ -74,7 +74,7 @@ impl Upkeep {
|
||||
|
||||
fn open_log() -> Option<File> {
|
||||
static N: AtomicU32 = AtomicU32::new(0);
|
||||
let home = std::env::var_os("HOME").or_else(|| std::env::var_os("USERPROFILE"))?;
|
||||
let home = raea_io_home::user_home()?;
|
||||
let dir = PathBuf::from(home).join(".raea").join("logs");
|
||||
if let Err(e) = std::fs::create_dir_all(&dir) {
|
||||
eprintln!("raea-runtime-jsengine: no heap log in {}: {e}", dir.display());
|
||||
|
||||
@@ -6,6 +6,7 @@ description = "Matchmove: a clip's camera solved for <Matchmove>, as `raea track
|
||||
license = "FSL-1.1-ALv2"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-io-assets = { path = "../../io/assets" }
|
||||
raea-native = { path = "../../engine/native", default-features = false }
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
|
||||
@@ -70,7 +70,7 @@ fn answer(store: &raea_io_assets::Store, a: &raea_io_assets::Asset) -> R<Value>
|
||||
/// `raea track CLIP ...`: the clip's camera solved once and kept; what it found.
|
||||
pub fn track(args: &[String]) -> R<String> {
|
||||
let (clip, params) = parse(args)?;
|
||||
let clip = clip.canonicalize().map_err(|e| format!("{}: {e}", clip.display()))?;
|
||||
let clip = dunce::canonicalize(&clip).map_err(|e| format!("{}: {e}", clip.display()))?;
|
||||
let dir = PathBuf::from(flag(args, "--dir").unwrap_or_else(|| ".".into()));
|
||||
let store = raea_io_assets::Store::beside(&dir.join("edit.tsx"));
|
||||
let t0 = std::time::Instant::now();
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "A composition's frames read into worlds of facts (docs/direction.feature DR1): React stepped with nothing drawn, its 3D, its page laid out and its timeline as entities with components"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
raea-core-scene = { path = "../../core/scene" }
|
||||
raea-runtime-scene = { path = "../scene" }
|
||||
|
||||
Loaded 100 of 145 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user