mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 12:44:11 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b54136c4af | ||
|
|
450d873984 | ||
|
|
c188cf8bd7 | ||
|
|
e388258bff | ||
|
|
5cf62e80ee | ||
|
|
57f3ef8db3 | ||
|
|
a927fbb027 | ||
|
|
f4139a5a7a | ||
|
|
b4f6b6ab7a | ||
|
|
451afc7bbf |
No files matched your search
Generated
+54
@@ -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",
|
||||
@@ -13927,8 +13938,10 @@ dependencies = [
|
||||
name = "raea-app-registry"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"oxc",
|
||||
"raea-core-facts",
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -13936,6 +13949,7 @@ dependencies = [
|
||||
name = "raea-app-solid"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-app-judge",
|
||||
"raea-core-facts",
|
||||
"raea-core-meshcheck",
|
||||
@@ -13949,6 +13963,7 @@ dependencies = [
|
||||
name = "raea-app-sound"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-io-media",
|
||||
"raea-runtime-bundle",
|
||||
"raea-runtime-export",
|
||||
@@ -13960,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",
|
||||
@@ -13969,6 +13985,7 @@ dependencies = [
|
||||
name = "raea-app-tools"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-io-assets",
|
||||
"raea-io-gen",
|
||||
"raea-io-home",
|
||||
@@ -13983,10 +14000,12 @@ dependencies = [
|
||||
name = "raea-app-workspace"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-app-check",
|
||||
"raea-app-registry",
|
||||
"raea-core-brief",
|
||||
"raea-core-facts",
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -14058,6 +14077,7 @@ dependencies = [
|
||||
"chacha20 0.10.2",
|
||||
"indexmap",
|
||||
"nonmax",
|
||||
"raea-io-home",
|
||||
"raea-sys-parity",
|
||||
"rand 0.10.3",
|
||||
]
|
||||
@@ -14141,6 +14161,7 @@ name = "raea-bridge-bench"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-alloc",
|
||||
"raea-core-wire",
|
||||
@@ -14165,6 +14186,7 @@ name = "raea-bundle"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dunce",
|
||||
"lightningcss",
|
||||
"oxc",
|
||||
"raea-io-home",
|
||||
@@ -14200,6 +14222,7 @@ name = "raea-cli"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"dunce",
|
||||
"raea-app-capcut",
|
||||
"raea-app-check",
|
||||
"raea-app-ci",
|
||||
@@ -14280,6 +14303,7 @@ version = "0.1.0"
|
||||
name = "raea-core-facts"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-core-brief",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -14457,6 +14481,7 @@ dependencies = [
|
||||
name = "raea-io-assets"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-io-home",
|
||||
"ruzstd",
|
||||
@@ -14479,6 +14504,7 @@ dependencies = [
|
||||
name = "raea-io-capcut"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -14507,6 +14533,7 @@ dependencies = [
|
||||
name = "raea-io-gen"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-io-gen-comfy",
|
||||
"raea-io-gen-core",
|
||||
@@ -14546,6 +14573,7 @@ dependencies = [
|
||||
name = "raea-io-home"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"serde_json",
|
||||
"url",
|
||||
]
|
||||
@@ -14623,6 +14651,7 @@ dependencies = [
|
||||
name = "raea-io-shell"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"flate2",
|
||||
"htmd",
|
||||
"raea-core-calls",
|
||||
@@ -14663,6 +14692,7 @@ name = "raea-modules"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"deno_ast",
|
||||
"dunce",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -14670,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",
|
||||
@@ -14698,6 +14730,7 @@ dependencies = [
|
||||
"bevy",
|
||||
"blitz-dom",
|
||||
"blitz-html",
|
||||
"dunce",
|
||||
"image",
|
||||
"parley",
|
||||
"raea-core-wire",
|
||||
@@ -14770,6 +14803,7 @@ dependencies = [
|
||||
"bevy",
|
||||
"blitz-dom",
|
||||
"raea-gpu-device",
|
||||
"raea-io-home",
|
||||
"raea-runtime-bake",
|
||||
"raea-runtime-dom",
|
||||
"raea-runtime-js",
|
||||
@@ -14817,6 +14851,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bytemuck",
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-program",
|
||||
"raea-core-shape",
|
||||
@@ -15043,6 +15078,7 @@ dependencies = [
|
||||
name = "raea-runtime-bundle-lib"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"libloading",
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
@@ -15162,6 +15198,7 @@ name = "raea-runtime-export"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-facts",
|
||||
"raea-core-program",
|
||||
@@ -15231,6 +15268,7 @@ dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bevy",
|
||||
"cpal 0.15.3",
|
||||
"dunce",
|
||||
"raea-bevy-world",
|
||||
"raea-core-wire",
|
||||
"raea-io-home",
|
||||
@@ -15249,6 +15287,7 @@ name = "raea-runtime-jsengine"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"objc2 0.6.5",
|
||||
"raea-io-home",
|
||||
"rquickjs",
|
||||
]
|
||||
|
||||
@@ -15258,6 +15297,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"cpal 0.15.3",
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-program",
|
||||
"raea-gpu-device",
|
||||
@@ -15463,6 +15503,7 @@ dependencies = [
|
||||
name = "raea-runtime-track"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-io-assets",
|
||||
"raea-native",
|
||||
"raea-runtime-bundle",
|
||||
@@ -15516,6 +15557,7 @@ name = "raea-runtime-world"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-facts",
|
||||
"raea-core-scene",
|
||||
@@ -15580,6 +15622,7 @@ name = "raea-sys-bake"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
"raea-io-home",
|
||||
"rapier3d",
|
||||
"serde_json",
|
||||
"sha2 0.10.9",
|
||||
@@ -15618,6 +15661,7 @@ dependencies = [
|
||||
"half",
|
||||
"image",
|
||||
"ort",
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
"raea-sys-ml",
|
||||
"rustfft",
|
||||
@@ -15691,6 +15735,7 @@ name = "raea-sys-fingerprint"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"raea-io-home",
|
||||
"raea-sys-columns",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -15714,6 +15759,7 @@ name = "raea-sys-fingerprint-use"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dunce",
|
||||
"fastrand",
|
||||
"image",
|
||||
"raea-sys-columns",
|
||||
@@ -15766,7 +15812,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",
|
||||
@@ -15851,6 +15899,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"block2 0.6.2",
|
||||
"dunce",
|
||||
"half",
|
||||
"objc2 0.6.5",
|
||||
"objc2-app-kit 0.3.2",
|
||||
@@ -15893,6 +15942,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"mlx-rs",
|
||||
"raea-io-home",
|
||||
"raea-sys-ml",
|
||||
"raea-sys-mlx",
|
||||
"serde_json",
|
||||
@@ -16011,6 +16061,7 @@ name = "raea-sys-ml"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dunce",
|
||||
"half",
|
||||
"ort",
|
||||
"raea-io-home",
|
||||
@@ -16057,6 +16108,7 @@ dependencies = [
|
||||
"bevy",
|
||||
"blitz-dom",
|
||||
"blitz-traits",
|
||||
"dunce",
|
||||
"percent-encoding",
|
||||
"raea-io-net",
|
||||
"raea-sys-image",
|
||||
@@ -16207,6 +16259,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ort",
|
||||
"raea-io-home",
|
||||
"raea-sys-ml",
|
||||
"serde_json",
|
||||
"tokenizers",
|
||||
@@ -16299,6 +16352,7 @@ dependencies = [
|
||||
"objc2-core-video",
|
||||
"objc2-foundation 0.3.2",
|
||||
"objc2-vision",
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
"raea-sys-layout",
|
||||
"serde",
|
||||
|
||||
@@ -32,14 +32,42 @@
|
||||
|
||||
---
|
||||
|
||||
> **v0.1.1** is raea's first full release: the engine and, for the first time, the desktop app, on macOS (Apple
|
||||
> Silicon), Linux (x86_64) and, newest and least tested, Windows (x86_64). raea is young: expect rough edges and gaps
|
||||
> in the docs.
|
||||
> **0.1.6** (17 November 2026) is the latest release: the engine and the desktop app on macOS (Apple Silicon), Linux
|
||||
> (x86_64) and, newest and least tested, Windows 10 and 11 (x86_64). raea is young and moves fast, with a release most
|
||||
> days since 0.1.1 on 11 November: expect rough edges, and tell us what you hit in an
|
||||
> [issue](https://github.com/shinyobjectz/raea/issues), or from your agent with `raea bug`.
|
||||
|
||||
## The app
|
||||
|
||||
The raea app is where you make video and games with your AI. Download it from [raea.io](https://raea.io) for the Mac,
|
||||
Windows or Linux. It tells you when a new version is out; on the Mac it updates itself.
|
||||
The raea app is where you make video, 3D and games with your AI. You ask in a chat; your own AI (Claude, ChatGPT, Kimi
|
||||
or a local model) writes the raea code and renders it; what it makes lands in the project's feed, where you watch it,
|
||||
scrub it, mark it up and send it back with notes. Download it from [raea.io](https://raea.io) for the Mac, Windows or
|
||||
Linux. It tells you when a new version is out; on the Mac it updates itself.
|
||||
|
||||
<p align="center">
|
||||
<a href="https://media.raea.io/#goose-learns-raea"><img src="docs/readme/goose-learns-raea.jpg" width="720" alt="The raea app tutorial"></a>
|
||||
</p>
|
||||
|
||||
New to the app? **[Watch the tutorial](https://media.raea.io/#goose-learns-raea)** (5:50).
|
||||
|
||||
What the app does now:
|
||||
|
||||
- **The chat comes first** (0.1.5): your projects in a rail, the conversation in the middle, and `/goal` to keep an
|
||||
agent going until a condition you set holds.
|
||||
- **A timeline you edit by hand** (0.1.4): trim, split and move clips, speed curves, freeze frames and keys, the way
|
||||
CapCut works, under every film, sound and scene.
|
||||
- **Scenes you walk around in** (0.1.3): your agent posts a 3D scene and you walk through it, pin comments in it and
|
||||
move its parts by hand; every change is written into the scene's own code.
|
||||
- **Index** (0.1.5): your folders, drives and Apple Photos made searchable by what's in them, on your Mac. On an M5 Pro,
|
||||
10,000 pictures were searchable in under a minute.
|
||||
- **Review** (0.1.6): each project has a Review tab, every comment you leave reaches the agent, and export is one
|
||||
window.
|
||||
- **Lighter** (0.1.6): the window gives back memory it's finished with and rests when nothing changes, 34% less CPU
|
||||
at rest.
|
||||
|
||||
The app and the engine are free. Pro adds cloud storage, search across your computers and publishing; Team puts up to
|
||||
five people on one plan ([pricing](https://raea.io/pricing/)). Each release's notes are on the
|
||||
[releases page](https://github.com/shinyobjectz/raea/releases).
|
||||
|
||||
## Install
|
||||
|
||||
@@ -92,12 +120,19 @@ floor (`raea check hello.mp4`). `raea init` starts a project, and `raea --help`
|
||||
- **Games.** Input, physics, sound and 3D, played live with `raea play`, and exported as a program of their own
|
||||
(`raea export-game`).
|
||||
- **3D.** Scenes in TypeScript drawn by [Bevy](https://bevyengine.org) 0.20: cameras, lights, materials, glTF models,
|
||||
Gaussian splats, and Bevy plugins compiled into the engine.
|
||||
Gaussian splats, and Bevy plugins compiled into the engine. three.js work runs as it's written: a React Three Fiber
|
||||
scene inside `<R3F>`, or a three.js page's script inside `<Three program>`.
|
||||
- **Sound.** One mixer for live play and offline render, instruments and effects, and local models for foley and
|
||||
instrument notes (`raea sao`, `raea tokensynth`).
|
||||
- **Built for agents.** Everything it draws stays queryable as data, so an agent can render a frame, look at it, and
|
||||
fix what's wrong without a person in the loop.
|
||||
|
||||
## Made in raea
|
||||
|
||||
Films, music videos, a tutorial and a game made with raea are on [media.raea.io](https://media.raea.io). Six of them
|
||||
come with their source in [raea-films](https://github.com/shinyobjectz/raea-films): each project's code under
|
||||
Apache-2.0, to read, render and take apart, and its models, textures and sound for anyone with a free raea account.
|
||||
|
||||
## Use it from your agent
|
||||
|
||||
- **Agent skills.** They live in [raea-skills](https://github.com/shinyobjectz/raea-skills), pinned here as
|
||||
@@ -108,6 +143,9 @@ floor (`raea check hello.mp4`). `raea init` starts a project, and `raea --help`
|
||||
folder of raea-skills, and `/plugin marketplace add shinyobjectz/raea` installs the same one.
|
||||
- **Craft guides.** `raea guide` prints the floor every edit is held to and the guides for pitches, explainers, stories,
|
||||
games, motion, music and layout. `raea context PROJECT` says what to read before working on a project.
|
||||
- **Bug reports.** When an agent finds a bug in raea itself, `raea bug TITLE --text TEXT` sends it to raea's server
|
||||
with raea's version and the OS, no account needed. It sends words only: paths, emails and keys are taken out before
|
||||
it goes, and `--dry-run` prints what would go.
|
||||
|
||||
## Build from source
|
||||
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -7,8 +7,10 @@ publish = false
|
||||
description = "`raea workspace`, `raea project` and `raea controller`: a workspace's folders, projects and controllers, each change a commit"
|
||||
|
||||
[dependencies]
|
||||
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" }
|
||||
|
||||
@@ -7,8 +7,10 @@ publish = false
|
||||
description = "A raea project's compositions, components and controllers, read from their source without running it, and lint for what isn't connected (docs/projects.feature PJ8)"
|
||||
|
||||
[dependencies]
|
||||
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" }
|
||||
@@ -157,7 +157,7 @@ pub(crate) fn resolve(from: &Path, spec: &str) -> Option<PathBuf> {
|
||||
}
|
||||
tries.extend([base.join("index.tsx"), base.join("index.ts")]);
|
||||
let found = tries.into_iter().find(|p| p.is_file())?;
|
||||
Some(std::fs::canonicalize(&found).unwrap_or(found))
|
||||
Some(dunce::canonicalize(&found).unwrap_or(found))
|
||||
}
|
||||
|
||||
/// An import of a file (not a package): relative, absolute, or the workspace's shared/ (@shared/...).
|
||||
@@ -183,7 +183,7 @@ fn manifest(path: &Path) -> Option<Value> {
|
||||
/// The folder's registry. `overridden`: the controller ids the project's overrides name, each checked against the
|
||||
/// controllers there (the folder's and its workspace's controllers/).
|
||||
pub fn scan(dir: &Path, overridden: &[String]) -> Registry {
|
||||
let dir = std::fs::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf());
|
||||
let dir = dunce::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf());
|
||||
let project = up(&dir, ".raea/project").is_some();
|
||||
let mut found = Vec::new();
|
||||
sources(&dir, "", 0, &mut found);
|
||||
@@ -192,7 +192,7 @@ pub fn scan(dir: &Path, overridden: &[String]) -> Registry {
|
||||
.map(|(path, rel)| {
|
||||
let src = std::fs::read_to_string(&path).unwrap_or_default();
|
||||
let facts = read::read(&src, rel.ends_with(".tsx"));
|
||||
File { path: std::fs::canonicalize(&path).unwrap_or(path), rel, facts }
|
||||
File { path: dunce::canonicalize(&path).unwrap_or(path), rel, facts }
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
@@ -74,7 +74,10 @@ pub(super) fn lint(reg: &Registry, files: &[File], used_by: &BTreeMap<String, BT
|
||||
let comp_files: BTreeSet<&str> = reg.compositions.iter().map(|c| c.file.as_str()).collect();
|
||||
let controller_files: BTreeSet<&str> = reg.controllers.iter().map(|c| c.file.as_str()).collect();
|
||||
// the workspace's shared/, which a project reaches as @shared/
|
||||
let shared = super::up(®.dir, ".raea/workspace").map(|w| w.join("shared")).map(|s| s.canonicalize().unwrap_or(s));
|
||||
let shared = super::up(®.dir, ".raea/workspace").map(|w| {
|
||||
let s = w.join("shared");
|
||||
dunce::canonicalize(&s).unwrap_or(s)
|
||||
});
|
||||
|
||||
for f in files {
|
||||
if let Some(why) = &f.facts.broken {
|
||||
@@ -102,7 +105,7 @@ pub(super) fn lint(reg: &Registry, files: &[File], used_by: &BTreeMap<String, BT
|
||||
"outside",
|
||||
format!("imports {} from outside the project", tilde(&to)),
|
||||
&match in_shared {
|
||||
Some(r) => format!("import it by the workspace's name for it: \"@shared/{}\"", r.with_extension("").display()),
|
||||
Some(r) => format!("import it by the workspace's name for it: \"@shared/{}\"", r.with_extension("").to_string_lossy().replace(std::path::MAIN_SEPARATOR, "/")),
|
||||
None => "move it to the workspace's shared/ and import it as @shared/<kind>/<name>, or copy it into the project (raea component add, for raea's sets)".into(),
|
||||
},
|
||||
))
|
||||
|
||||
@@ -35,7 +35,7 @@ mod tempdir {
|
||||
static N: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
|
||||
let d = std::env::temp_dir().join(format!("raea-registry-{}-{}", std::process::id(), N.fetch_add(1, std::sync::atomic::Ordering::Relaxed)));
|
||||
std::fs::create_dir_all(&d).unwrap();
|
||||
Dir(std::fs::canonicalize(&d).unwrap())
|
||||
Dir(dunce::canonicalize(&d).unwrap())
|
||||
}
|
||||
}
|
||||
impl Drop for Dir {
|
||||
|
||||
@@ -49,6 +49,11 @@ fn old_briefs(dir: &Path, depth: usize, out: &mut Vec<Finding>) {
|
||||
|
||||
/// A committed git-config file's keys this version writes, and its include from the repo's config.
|
||||
fn format(repo: &Path, file: &Path, keys: &[(&str, String)], out: &mut Vec<Finding>) {
|
||||
// first, so its fix runs before the others: with it there, every git command in the repo fails (#169)
|
||||
if crate::repair::has_verbatim_include(repo) {
|
||||
let says = format!("{}: its git config includes a \\\\?\\ path Git for Windows can't open (written by raea 0.1.5 or 0.1.6 on Windows), so every git command in it fails; --fix replaces it", repo.display());
|
||||
out.push(Finding { says, fix: Fix::Include(repo.to_path_buf(), file.to_path_buf()) });
|
||||
}
|
||||
for (k, v) in keys {
|
||||
if get(file, k).is_none() {
|
||||
out.push(Finding { says: format!("{}: no {k} (an older format); --fix sets it to {v}", file.display()), fix: Fix::Set(file.to_path_buf(), k.to_string(), v.clone()) });
|
||||
@@ -56,7 +61,7 @@ fn format(repo: &Path, file: &Path, keys: &[(&str, String)], out: &mut Vec<Findi
|
||||
}
|
||||
// only a folder that is its own repo includes its file (a workspace, a split project); an inline project shares
|
||||
// the workspace's repo, whose config must not take one project's keys
|
||||
let own = git(repo, &["rev-parse", "--show-toplevel"]).ok().and_then(|t| Path::new(&t).canonicalize().ok()) == repo.canonicalize().ok();
|
||||
let own = git(repo, &["rev-parse", "--show-toplevel"]).ok().and_then(|t| dunce::canonicalize(Path::new(&t)).ok()) == dunce::canonicalize(repo).ok();
|
||||
let first = keys.first().map(|(k, _)| *k).unwrap_or_default();
|
||||
let read = git(repo, &["config", first]).ok().filter(|v| !v.is_empty());
|
||||
if own && read.is_none() && get(file, first).is_some() {
|
||||
@@ -107,7 +112,7 @@ pub fn registry_dir(from: &Path) -> Option<PathBuf> {
|
||||
if let Some(p) = up(from, ".raea/project") {
|
||||
return Some(p);
|
||||
}
|
||||
let from = from.canonicalize().unwrap_or_else(|_| from.to_path_buf());
|
||||
let from = dunce::canonicalize(from).unwrap_or_else(|_| from.to_path_buf());
|
||||
(up(&from, ".raea/workspace").as_deref() != Some(from.as_path())).then_some(from)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use serde_json::json;
|
||||
mod controllers;
|
||||
pub mod doctor;
|
||||
mod literal;
|
||||
mod repair;
|
||||
pub mod next;
|
||||
pub mod registry;
|
||||
mod storage;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
//! Workspaces raea 0.1.5 and 0.1.6 broke on Windows (#169): their include.path is a relative climb glued to a `\\?\`
|
||||
//! path (`../../../../\\?\C:/\/Users/...`), which Git for Windows can't open, so every git command in the repo failed
|
||||
//! with "Invalid argument", `git rev-parse` too. A repair can't ask git, then: it reads the repo's config file itself
|
||||
//! and drops those lines, and the include is added again the right way (workspace::include, run by `raea workspace
|
||||
//! init` inside it, `raea workspace adopt` and `raea doctor --fix`).
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// The repo's own config file, found without git: `.git/config`, or the config in the folder a `.git` file names (a
|
||||
/// submodule's, under the workspace's .git/modules).
|
||||
fn config_file(repo: &Path) -> Option<PathBuf> {
|
||||
let dot = repo.join(".git");
|
||||
if dot.is_dir() {
|
||||
return Some(dot.join("config"));
|
||||
}
|
||||
let text = std::fs::read_to_string(&dot).ok()?;
|
||||
let dir = PathBuf::from(text.lines().find_map(|l| l.strip_prefix("gitdir:"))?.trim());
|
||||
Some(if dir.is_absolute() { dir } else { repo.join(dir) }.join("config"))
|
||||
}
|
||||
|
||||
/// The config's text without the `path = ...\\?\...` lines of its [include] sections, and whether there were any.
|
||||
/// [includeIf] sections and every other line are kept as they are.
|
||||
pub(crate) fn without_verbatim(text: &str) -> (String, bool) {
|
||||
let mut section = String::new();
|
||||
let mut dropped = false;
|
||||
let eol = if text.contains("\r\n") { "\r\n" } else { "\n" };
|
||||
let kept: Vec<&str> = text
|
||||
.lines()
|
||||
.filter(|l| {
|
||||
let t = l.trim();
|
||||
if t.starts_with('[') {
|
||||
section = t.trim_start_matches('[').split(']').next().unwrap_or_default().trim().to_ascii_lowercase();
|
||||
return true;
|
||||
}
|
||||
let key = t.split('=').next().unwrap_or_default().trim();
|
||||
let bad = section == "include" && key.eq_ignore_ascii_case("path") && t.contains("?\\");
|
||||
dropped |= bad;
|
||||
!bad
|
||||
})
|
||||
.collect();
|
||||
(kept.join(eol) + eol, dropped)
|
||||
}
|
||||
|
||||
/// Whether the repo's config holds an include git can't open on Windows (what `raea doctor` reports).
|
||||
pub fn has_verbatim_include(repo: &Path) -> bool {
|
||||
config_file(repo).and_then(|c| std::fs::read_to_string(c).ok()).is_some_and(|t| without_verbatim(&t).1)
|
||||
}
|
||||
|
||||
/// Drops those includes from the repo's config. Ok(true) when there were some.
|
||||
pub(crate) fn drop_verbatim_includes(repo: &Path) -> Result<bool, String> {
|
||||
let Some(cfg) = config_file(repo) else { return Ok(false) };
|
||||
let Ok(text) = std::fs::read_to_string(&cfg) else { return Ok(false) };
|
||||
let (fixed, dropped) = without_verbatim(&text);
|
||||
if dropped {
|
||||
std::fs::write(&cfg, fixed).map_err(|e| format!("{}: {e}", cfg.display()))?;
|
||||
}
|
||||
Ok(dropped)
|
||||
}
|
||||
@@ -22,7 +22,7 @@ fn a_spec_module_is_tidy_typescript() {
|
||||
|
||||
#[test]
|
||||
fn up_finds_the_nearest_marker() {
|
||||
let root = std::env::temp_dir().canonicalize().unwrap().join(format!("raea-ws-up-{}", std::process::id()));
|
||||
let root = dunce::canonicalize(std::env::temp_dir()).unwrap().join(format!("raea-ws-up-{}", std::process::id()));
|
||||
let deep = root.join("projects/launch/media");
|
||||
std::fs::create_dir_all(&deep).unwrap();
|
||||
std::fs::create_dir_all(root.join(".raea")).unwrap();
|
||||
@@ -139,6 +139,43 @@ fn the_root_with_none_set() {
|
||||
assert_eq!(default_root(&synced), synced.join("raea"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_workspace_reads_back_through_git() {
|
||||
// Windows: canonicalize() gives \\?\C:\..., a path Git for Windows can neither read nor lock, and one that shares no
|
||||
// prefix with the C:/... git prints, so the include climbed to the root (../../../../\\?\C:/...) and every git
|
||||
// command in the workspace failed; ids were never written and nothing read back (0.1.5, 0.1.6)
|
||||
let ws = scratch("plain");
|
||||
let made = crate::workspace::workspace(&["adopt".into(), ws.display().to_string(), "--name".into(), "Plain".into()]);
|
||||
assert!(made.is_ok(), "{made:?}");
|
||||
let git = |dir: &Path, a: &[&str]| {
|
||||
let o = std::process::Command::new("git").arg("-C").arg(dir).args(a).output().unwrap();
|
||||
(o.status.success(), String::from_utf8_lossy(&o.stdout).trim().to_string(), String::from_utf8_lossy(&o.stderr).trim().to_string())
|
||||
};
|
||||
let (ok, inc, err) = git(&ws, &["config", "--get-all", "include.path"]);
|
||||
assert!(ok && inc == "../.raea/workspace", "include.path {inc:?} {err}");
|
||||
let (ok, id, err) = git(&ws, &["config", "workspace.id"]);
|
||||
assert!(ok && id.starts_with("ws_"), "workspace.id {id:?} {err}");
|
||||
let found = up(&ws.join("projects"), ".raea/workspace").expect("up finds the workspace");
|
||||
assert!(!found.to_string_lossy().starts_with(r"\\?\"), "{}", found.display());
|
||||
crate::workspace::new_project_in(&found, "Desk", None).unwrap();
|
||||
let (ok, pid, err) = git(&ws.join("projects/desk"), &["config", "-f", ".raea/project", "project.id"]);
|
||||
assert!(ok && pid.starts_with("pj_"), "project.id {pid:?} {err}");
|
||||
let _ = std::fs::remove_dir_all(&ws);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_include_path_is_relative_with_slashes() {
|
||||
use crate::workspace::relative;
|
||||
assert_eq!(relative(Path::new("/w/.git"), Path::new("/w/.raea/workspace")), "../.raea/workspace");
|
||||
assert_eq!(relative(Path::new("/w/.git/modules/projects/p"), Path::new("/w/projects/p/.raea/project")), "../../../../projects/p/.raea/project");
|
||||
#[cfg(windows)]
|
||||
{
|
||||
// git's C:/... and a plain C:\... are one root; another drive is named whole, not climbed to
|
||||
assert_eq!(relative(Path::new("C:/w/.git"), Path::new(r"C:\w\.raea\workspace")), "../.raea/workspace");
|
||||
assert_eq!(relative(Path::new(r"C:\w\.git"), Path::new(r"D:\o\.raea\workspace")), "D:/o/.raea/workspace");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_new_workspace_and_project_have_the_layout() {
|
||||
// docs/layout.feature LY1: a folder per kind in the project and in the workspace's shared/, no media/ brand/ parts/
|
||||
@@ -166,3 +203,39 @@ fn a_new_workspace_and_project_have_the_layout() {
|
||||
assert!(tracked.contains("projects/desk-test/components/.gitkeep") && tracked.contains("shared/assets/.gitkeep"), "{tracked}");
|
||||
let _ = std::fs::remove_dir_all(&ws);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_verbatim_include_is_dropped_and_nothing_else() {
|
||||
// .git/config as raea 0.1.6 left it on Windows (#169, read off the test PC), with an [includeIf] and a good include
|
||||
let text = "[core]\n\trepositoryformatversion = 0\n[include]\n\tpath = ../../../../../../../../\\\\\\\\?\\\\C:/\\\\/Users/you/Documents/raea/acme/.raea/workspace\n[includeIf \"gitdir:~/x/\"]\n\tpath = ../keep?\\\\x\n[include]\n\tpath = ../.raea/workspace\n";
|
||||
let (fixed, dropped) = crate::repair::without_verbatim(text);
|
||||
assert!(dropped);
|
||||
assert_eq!(fixed, "[core]\n\trepositoryformatversion = 0\n[include]\n[includeIf \"gitdir:~/x/\"]\n\tpath = ../keep?\\\\x\n[include]\n\tpath = ../.raea/workspace\n");
|
||||
assert_eq!(crate::repair::without_verbatim(&fixed).0, fixed);
|
||||
assert!(!crate::repair::without_verbatim("[include]\r\n\tpath = ../.raea/workspace\r\n").1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_workspace_0_1_6_broke_is_repaired() {
|
||||
// updated from 0.1.6: its include names a \\?\ path; doctor says so, and adopt (as init inside it) puts it right
|
||||
let ws = scratch("repair");
|
||||
crate::workspace::workspace(&["adopt".into(), ws.display().to_string(), "--name".into(), "Repair".into()]).unwrap();
|
||||
let cfg = ws.join(".git/config");
|
||||
let bad = "\tpath = ../../../../\\\\\\\\?\\\\C:/\\\\/Users/you/Documents/raea/repair/.raea/workspace\n";
|
||||
let text = std::fs::read_to_string(&cfg).unwrap().replace("\tpath = ../.raea/workspace\n", bad);
|
||||
std::fs::write(&cfg, text).unwrap();
|
||||
// on Windows this is #169 itself: Git for Windows refuses the include, so every git command in the repo fails
|
||||
let status = || std::process::Command::new("git").arg("-C").arg(&ws).args(["status", "--short"]).output().unwrap();
|
||||
if cfg!(windows) {
|
||||
assert!(!status().status.success(), "git ran in a repo whose include names a \\\\?\\ path");
|
||||
}
|
||||
assert!(crate::repair::has_verbatim_include(&ws));
|
||||
let said: Vec<String> = crate::doctor::findings(&ws, &[], "test").into_iter().filter(|f| f.fixable()).map(|f| f.says).collect();
|
||||
assert!(said.iter().any(|s| s.contains("Git for Windows can't open")), "{said:?}");
|
||||
crate::workspace::workspace(&["adopt".into(), ws.display().to_string()]).unwrap();
|
||||
assert!(!crate::repair::has_verbatim_include(&ws));
|
||||
let o = std::process::Command::new("git").arg("-C").arg(&ws).args(["config", "--get-all", "include.path"]).output().unwrap();
|
||||
assert_eq!(String::from_utf8_lossy(&o.stdout).trim(), "../.raea/workspace");
|
||||
assert!(status().status.success(), "git status after the repair: {}", String::from_utf8_lossy(&status().stderr));
|
||||
let _ = std::fs::remove_dir_all(&ws);
|
||||
}
|
||||
@@ -92,7 +92,9 @@ pub(crate) fn new_id(prefix: &str) -> String {
|
||||
/// Where workspaces live on this machine: `git config --global raea.root`, else default_root.
|
||||
pub fn root() -> PathBuf {
|
||||
let set = config(None, &["--global", "raea.root"]).ok().filter(|s| !s.is_empty());
|
||||
let home = std::env::var_os("HOME").map(PathBuf::from).unwrap_or_default();
|
||||
// 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 = 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),
|
||||
@@ -116,8 +118,14 @@ pub fn default_root(home: &Path) -> PathBuf {
|
||||
/// The include in a repo's own config that makes `git config` read a committed file. Idempotent; the path is relative
|
||||
/// to the config file, which for a submodule lives under the workspace's .git/modules.
|
||||
pub(crate) fn include(repo: &Path, file: &Path) -> R<()> {
|
||||
// both ends the same way, plain (dunce): on Windows git prints C:/... and canonicalize() alone gave \\?\C:\..., which
|
||||
// share no root, so the include climbed to the drive and named the file by its \\?\ path, and every git command in
|
||||
// the workspace failed ("Invalid argument") from its first commit (0.1.5, 0.1.6). Such an include goes first: with
|
||||
// it there, the rev-parse below fails too.
|
||||
crate::repair::drop_verbatim_includes(repo)?;
|
||||
let cfg = PathBuf::from(git(repo, &["rev-parse", "--path-format=absolute", "--git-path", "config"])?);
|
||||
let file = file.canonicalize().map_err(|e| format!("{}: {e}", file.display()))?;
|
||||
let cfg = dunce::canonicalize(&cfg).unwrap_or(cfg);
|
||||
let file = dunce::canonicalize(file).map_err(|e| format!("{}: {e}", file.display()))?;
|
||||
let rel = relative(cfg.parent().unwrap_or(Path::new("/")), &file);
|
||||
let have = config(Some(&cfg), &["--get-all", "include.path"]).unwrap_or_default();
|
||||
if have.lines().any(|l| l.trim() == rel) {
|
||||
@@ -126,9 +134,14 @@ pub(crate) fn include(repo: &Path, file: &Path) -> R<()> {
|
||||
config(Some(&cfg), &["--add", "include.path", &rel]).map(drop)
|
||||
}
|
||||
|
||||
fn relative(from: &Path, to: &Path) -> String {
|
||||
/// `to` from the folder `from`, '/' between its parts as git reads an include.path; `to` itself (with '/') when the two
|
||||
/// share no root, as two drives don't.
|
||||
pub(crate) fn relative(from: &Path, to: &Path) -> String {
|
||||
let (a, b): (Vec<_>, Vec<_>) = (from.components().collect(), to.components().collect());
|
||||
let same = a.iter().zip(&b).take_while(|(x, y)| x == y).count();
|
||||
if same == 0 {
|
||||
return to.to_string_lossy().replace(std::path::MAIN_SEPARATOR, "/");
|
||||
}
|
||||
let mut out: Vec<String> = std::iter::repeat_n("..".to_string(), a.len() - same).collect();
|
||||
out.extend(b[same..].iter().map(|c| c.as_os_str().to_string_lossy().into_owned()));
|
||||
out.join("/")
|
||||
@@ -213,7 +226,7 @@ fn init(name: Option<&str>, layout: Option<&str>) -> R<String> {
|
||||
/// An existing folder made a workspace in place: git when it isn't a repo, .raea/workspace, and each folder in it
|
||||
/// holding a brief.ts registered as an inline project. Nothing is moved or deleted.
|
||||
fn adopt(dir: &Path, name: Option<&str>, layout: Option<&str>) -> R<String> {
|
||||
let dir = dir.canonicalize().map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
let dir = dunce::canonicalize(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
let name = name.map(String::from).unwrap_or_else(|| dir.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default());
|
||||
make_workspace(&dir, &name, layout_of(layout)?)?;
|
||||
let mut found = vec![];
|
||||
@@ -244,7 +257,7 @@ pub(crate) fn make_workspace(dir: &Path, name: &str, layout: &str) -> R<()> {
|
||||
let parent = dir.parent().unwrap_or(Path::new("/"));
|
||||
if !dir.join(".git").exists() && parent.exists() {
|
||||
let top = git(parent, &["rev-parse", "--show-toplevel"]).ok().map(PathBuf::from);
|
||||
if top.is_some_and(|t| t.canonicalize().ok() == parent.canonicalize().ok()) {
|
||||
if top.is_some_and(|t| dunce::canonicalize(t).ok() == dunce::canonicalize(parent).ok()) {
|
||||
return Err(format!("{} would be a folder of the git repo {}: set where workspaces go, `git config --global raea.root ~/Documents/raea`", dir.display(), parent.display()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "A project as one world of facts in raea/ecs's form: its layers, text, parts, shots, clips and cues as entities with components, for any kind of piece"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
# a rule's taste form and controller field (rule.rs)
|
||||
raea-core-brief = { path = "../brief" }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
||||
@@ -44,15 +44,17 @@ pub struct Entry {
|
||||
pub despite: Vec<Despite>,
|
||||
}
|
||||
|
||||
/// The nearest folder at or above `from` that holds `marker` (.raea/workspace, .raea/project).
|
||||
/// The nearest folder at or above `from` that holds `marker` (.raea/workspace, .raea/project). Plain on Windows
|
||||
/// (C:\..., through dunce): canonicalize() alone gives \\?\C:\..., a path Git for Windows can neither read nor lock, so
|
||||
/// every id raea kept in git config read back empty and was never written (0.1.5, 0.1.6).
|
||||
pub fn up(from: &Path, marker: &str) -> Option<PathBuf> {
|
||||
let from = from.canonicalize().ok()?;
|
||||
let from = dunce::canonicalize(from).ok()?;
|
||||
from.ancestors().find(|d| d.join(marker).is_file()).map(Path::to_path_buf)
|
||||
}
|
||||
|
||||
/// A path made absolute through its nearest folder that exists (an output may not be written yet).
|
||||
fn real(p: &Path) -> PathBuf {
|
||||
if let Ok(c) = p.canonicalize() {
|
||||
if let Ok(c) = dunce::canonicalize(p) {
|
||||
return c;
|
||||
}
|
||||
match (p.parent().filter(|d| !d.as_os_str().is_empty()), p.file_name()) {
|
||||
@@ -61,10 +63,11 @@ fn real(p: &Path) -> PathBuf {
|
||||
}
|
||||
}
|
||||
|
||||
/// A path as the record names it: relative to the project when it's in it.
|
||||
/// A path as the record names it: relative to the project when it's in it, with '/' between its parts on Windows too (a
|
||||
/// project's record moves between machines, and `raea next` quotes it in commands).
|
||||
pub fn rel(project: &Path, p: &Path) -> String {
|
||||
let full = real(p);
|
||||
full.strip_prefix(project).map(|r| r.display().to_string()).unwrap_or_else(|_| full.display().to_string())
|
||||
full.strip_prefix(project).map(|r| r.to_string_lossy().replace(std::path::MAIN_SEPARATOR, "/")).unwrap_or_else(|_| full.display().to_string())
|
||||
}
|
||||
|
||||
/// The project's commit, with "+" when `of` (a path from the project; "." for all of it) differs from it.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 85 KiB |
@@ -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
|
||||
|
||||
@@ -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" }
|
||||
|
||||
@@ -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),
|
||||
});
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
//! The window's own chrome (--chrome inset, the desktop app): macOS's title bar made transparent with the page drawn
|
||||
//! under it, its traffic lights kept, and what a title bar does left to the page. The page knows from
|
||||
//! `globalThis.__raea_window` ({chrome, lights}: the lights' box in points, for the page to leave room for) and asks
|
||||
//! `globalThis.__raea_window` ({chrome, os, lights}: the system it runs on, std's name for it, so the page says "this
|
||||
//! PC" and Ctrl on Windows where a Mac's says "this Mac" and ⌘; the lights' box in points, for the page to leave room
|
||||
//! for) and asks
|
||||
//! through two host calls: `window.drag` (a press on the page's title area moves the window, as winit's drag_window
|
||||
//! does from that press) and `window.zoom` (a double-click there zooms, as a native title bar's does).
|
||||
|
||||
@@ -50,14 +52,28 @@ impl Chrome {
|
||||
json!({ "x": 7, "y": 6, "w": 54, "h": 14 })
|
||||
};
|
||||
let bar = if cfg!(all(target_os = "macos", feature = "window")) { 52 } else { 28 };
|
||||
let os = std::env::consts::OS;
|
||||
let v = match self {
|
||||
Self::Native => json!({ "chrome": "native" }),
|
||||
Self::Inset => json!({ "chrome": "inset", "lights": lights, "bar": bar }),
|
||||
Self::Native => json!({ "chrome": "native", "os": os }),
|
||||
Self::Inset => json!({ "chrome": "inset", "os": os, "lights": lights, "bar": bar }),
|
||||
};
|
||||
format!("globalThis.__raea_window = {v};")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// the page reads which system it's on from here (apps/app src/lib/machine.ts)
|
||||
#[test]
|
||||
fn the_preamble_names_the_system() {
|
||||
for c in [super::Chrome::Native, super::Chrome::Inset] {
|
||||
let p = c.preamble();
|
||||
let v: serde_json::Value = serde_json::from_str(p.strip_prefix("globalThis.__raea_window = ").unwrap().trim_end_matches(';')).unwrap();
|
||||
assert_eq!(v["os"], std::env::consts::OS, "{p}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The primary window, once winit has made it, given an empty unified toolbar (macOS): AppKit then draws a 52 pt title
|
||||
/// area with the traffic lights centred in it, as in an app with a toolbar, under the page (inset chrome only).
|
||||
#[cfg(all(target_os = "macos", feature = "window"))]
|
||||
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "raea's render engine: an edit's rows drawn by Bevy (3D) or the direct GPU path, its sound mixed, its video encoded"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
# a frame's rows as the passes read them (FrameRows, the edit, the clock, row helpers, bevy_api)
|
||||
raea-sys-frame = { path = "../../systems/frame" }
|
||||
# a part held where a hand has it, and wireframe (the app's scene inspector)
|
||||
|
||||
@@ -29,7 +29,7 @@ pub fn inserted_of(p: &Program) -> Vec<Tup> {
|
||||
}
|
||||
|
||||
pub fn dir_of(path: &str) -> PathBuf {
|
||||
std::fs::canonicalize(Path::new(path).parent().filter(|d| !d.as_os_str().is_empty()).unwrap_or(Path::new("."))).unwrap_or_else(|_| PathBuf::from("."))
|
||||
dunce::canonicalize(Path::new(path).parent().filter(|d| !d.as_os_str().is_empty()).unwrap_or(Path::new("."))).unwrap_or_else(|_| PathBuf::from("."))
|
||||
}
|
||||
|
||||
pub fn save_png(path: &Path, rgba: &[u8], w: u32, h: u32) -> Result<(), String> {
|
||||
|
||||
@@ -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"
|
||||
|
||||
Loaded 100 of 171 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user