diff --git a/Cargo.lock b/Cargo.lock index d6dde975790109ab93de4806352711bf594322f2..4bb36ae7427481d877e4457c8d52b9aa29f929fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1021,7 +1021,7 @@ dependencies = [ "pollster", "rustybuzz", "symphonia", - "theme", + "web-time", "wgpu", "zeno", ] diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml index a0f950602f369bcf560e6003b9f904389569b419..47e1c5f5877444b3e191c89561a6e46bb77af629 100644 --- a/crates/engine/Cargo.toml +++ b/crates/engine/Cargo.toml @@ -10,7 +10,6 @@ path = "src/bin/render_check.rs" [dependencies] bytemuck.workspace = true -cpal = "0.15" exr = "1.74" fontdb.workspace = true image.workspace = true @@ -18,10 +17,15 @@ model.workspace = true png.workspace = true pollster.workspace = true rustybuzz.workspace = true -symphonia = { version = "0.5", default-features = false, features = ["wav", "mp3", "flac", "ogg", "aac", "isomp4", "pcm"] } -theme.workspace = true wgpu.workspace = true zeno.workspace = true +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cpal = "0.15" +symphonia = { version = "0.5", default-features = false, features = ["wav", "mp3", "flac", "ogg", "aac", "isomp4", "pcm"] } + +[target.'cfg(target_arch = "wasm32")'.dependencies] +web-time = "1" + [target.'cfg(target_os = "macos")'.build-dependencies] cc = "1" diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 30afa4dad9c43cccdd0f128bdc7006de3fcf31d1..611f41dc3fcba11915bba38075049c44664987d6 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -1,8 +1,10 @@ +#[cfg(not(target_arch = "wasm32"))] pub mod audio; pub mod cache; pub mod cryptomatte; pub mod custom_shader; pub mod eval; +#[cfg(not(target_arch = "wasm32"))] pub mod export; pub mod media; pub mod optflow; @@ -12,14 +14,16 @@ pub mod ram_cache; pub mod scene3d; pub mod text_engine; +#[cfg(not(target_arch = "wasm32"))] pub use audio::{AudioPlayer, AudioTrack}; pub use cache::{ CacheMode, CachedTexture, DEFAULT_VRAM_BUDGET_MB, EvalStats, GpuCache, NodeCache, TexturePool, TexturePoolKey, TexturePoolStats, }; pub use eval::{DisplaySettings, Engine, create_texture}; +#[cfg(not(target_arch = "wasm32"))] pub use export::{ExportOptions, ExportProgress, ExportSummary, export_saver_png_sequence, select_saver}; pub use profile::{FrameProfile, NodeProfileEntry}; -pub use ram_cache::{ - DEFAULT_RAM_CACHE_MB, PrefetchJob, RamFrame, RamFrameCache, RamFrameKey, RamPrefetcher, -}; +pub use ram_cache::{DEFAULT_RAM_CACHE_MB, RamFrame, RamFrameCache, RamFrameKey}; +#[cfg(not(target_arch = "wasm32"))] +pub use ram_cache::{PrefetchJob, RamPrefetcher}; diff --git a/crates/engine/src/media.rs b/crates/engine/src/media.rs index fdb124b71d760588c918434cd022a77fd059d284..c4478ccca831c345901ecdd4eb1faa1ca3d65266 100644 --- a/crates/engine/src/media.rs +++ b/crates/engine/src/media.rs @@ -18,7 +18,7 @@ use model::{ClipSpec, ClsEntry, PolyPoint}; use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::process::Command; -use std::sync::Arc; +use std::sync::{Arc, RwLock}; #[derive(Clone)] pub struct DecodedImage { @@ -50,6 +50,50 @@ impl DecodedImage { const MAX_VIDEO_DECODERS: usize = 12; +struct VirtualFile { + parts: Vec, + bytes: Arc<[u8]>, +} + +/// In-memory files that shadow the filesystem for still and sequence loading, since `wasm32` has no `std::fs`. +static VIRTUAL_FILES: RwLock> = RwLock::new(Vec::new()); + +fn path_parts(path: &Path) -> Vec { + path.to_string_lossy() + .split(['/', '\\']) + .filter(|p| !p.is_empty() && *p != ".") + .map(str::to_owned) + .collect() +} + +/// Bytes of the virtual file sharing the longest run of trailing path components with `path`, so a +/// comp's absolute `Loader` path still finds a file registered under a dropped folder's relative path. +fn virtual_bytes(path: &Path) -> Option> { + let files = VIRTUAL_FILES.read().ok()?; + if files.is_empty() { + return None; + } + let want = path_parts(path); + let shared = |f: &VirtualFile| f.parts.iter().rev().zip(want.iter().rev()).take_while(|(a, b)| a == b).count(); + files + .iter() + .map(|f| (shared(f), f)) + .filter(|(n, _)| *n > 0) + .max_by_key(|(n, _)| *n) + .map(|(_, f)| Arc::clone(&f.bytes)) +} + +fn path_exists(path: &Path) -> bool { + virtual_bytes(path).is_some() || path.exists() +} + +fn open_image(path: &Path) -> Option { + match virtual_bytes(path) { + Some(bytes) => image::load_from_memory(&bytes).ok(), + None => image::open(path).ok(), + } +} + #[derive(Clone, Debug, PartialEq, Eq, Hash)] struct ImageCacheKey { path: PathBuf, @@ -84,6 +128,23 @@ impl MediaCache { } } + /// Registers `bytes` as the file at `path` for every `MediaCache` in the process. + pub fn insert_virtual_bytes(path: impl AsRef, bytes: impl Into>) { + let parts = path_parts(path.as_ref()); + let bytes = bytes.into(); + let Ok(mut files) = VIRTUAL_FILES.write() else { return }; + match files.iter_mut().find(|f| f.parts == parts) { + Some(existing) => existing.bytes = bytes, + None => files.push(VirtualFile { parts, bytes }), + } + } + + pub fn clear_virtual_bytes() { + if let Ok(mut files) = VIRTUAL_FILES.write() { + files.clear(); + } + } + pub fn clear(&mut self) { self.images.clear(); self.lru.clear(); @@ -271,7 +332,7 @@ impl MediaCache { false, )? } else { - let dyn_img = image::open(&resolved).ok()?; + let dyn_img = open_image(&resolved)?; let rgba_img = dyn_img.to_rgba8(); let size = [rgba_img.width(), rgba_img.height()]; let mut raw = rgba_img.into_raw(); @@ -301,7 +362,7 @@ pub fn resolve_clip_path(clip: &ClipSpec, frame: i64) -> Option { let digits = &stem[digit_start..]; let is_seq = len > 1 && (clip.start_frame >= 0 || !digits.is_empty()); if !is_seq || digits.is_empty() { - return base.exists().then(|| base.to_path_buf()); + return path_exists(base).then(|| base.to_path_buf()); } let seq_start = if clip.start_frame >= 0 { clip.start_frame } else { 0 }; @@ -329,7 +390,7 @@ pub fn resolve_clip_path(clip: &ClipSpec, frame: i64) -> Option { format!("{prefix}{idx:0width$}.{ext}") }; let candidate = base.with_file_name(new_name); - candidate.exists().then_some(candidate) + path_exists(&candidate).then_some(candidate) } #[cfg(test)] mod tests { @@ -855,4 +916,43 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + + #[test] + fn virtual_bytes_load_a_sequence_by_trailing_path() { + let png = |rgba: [u8; 4]| { + let mut out = std::io::Cursor::new(Vec::new()); + image::RgbaImage::from_pixel(2, 1, image::Rgba(rgba)) + .write_to(&mut out, image::ImageFormat::Png) + .unwrap(); + out.into_inner() + }; + MediaCache::insert_virtual_bytes("vf_proj\\vf_seq.0001.png", png([255, 0, 0, 255])); + MediaCache::insert_virtual_bytes("./vf_proj/vf_seq.0002.png", png([0, 255, 0, 255])); + let clip = ClipSpec { + filename: "/not/on/disk/vf_proj/vf_seq.0001.png".to_owned(), + alternate_filename: None, + start_frame: 1, + length: Some(2), + trim_in: 0, + trim_out: 1, + global_start: 0, + global_end: 1, + extend_first: 0, + extend_last: 0, + loop_clip: false, + reverse: false, + }; + let mut cache = MediaCache::new(64); + let (_, _, f0, from_disk) = cache.load_clip(&clip, 0, false, [None; 4]).unwrap(); + let (_, _, f1, _) = cache.load_clip(&clip, 1, false, [None; 4]).unwrap(); + assert!(from_disk); + assert_eq!((f0.size, &f0.rgba[..4]), ([2, 1], &[255, 0, 0, 255][..])); + assert_eq!(&f1.rgba[..4], &[0, 255, 0, 255]); + + MediaCache::insert_virtual_bytes("vf_proj/vf_seq.0002.png", png([0, 0, 255, 255])); + let (_, _, f1, _) = MediaCache::new(64).load_clip(&clip, 1, false, [None; 4]).unwrap(); + assert_eq!(&f1.rgba[..4], &[0, 0, 255, 255]); + assert!(path_exists(Path::new("elsewhere/vf_seq.0002.png"))); + assert!(!path_exists(Path::new("vf_proj/vf_seq.0003.png"))); + } } diff --git a/crates/engine/src/ram_cache.rs b/crates/engine/src/ram_cache.rs index 37ea27faf1c7d75c7cc4febb02fa256fc372be41..1c570b3983c862dce733318f00ff810a8b9545a3 100644 --- a/crates/engine/src/ram_cache.rs +++ b/crates/engine/src/ram_cache.rs @@ -7,11 +7,19 @@ //! - `RamPrefetcher` runs lookahead evaluation on a background thread with an atomic generation //! counter so scrubbing or editing cancels stale pre-fetch work immediately. +#[cfg(not(target_arch = "wasm32"))] use crate::eval::Engine; -use model::{Comp, NodeId}; +#[cfg(not(target_arch = "wasm32"))] +use model::Comp; +use model::NodeId; use std::collections::HashMap; -use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; -use std::sync::{Arc, Condvar, Mutex}; +#[cfg(not(target_arch = "wasm32"))] +use std::sync::atomic::AtomicBool; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::{Arc, Mutex}; +#[cfg(not(target_arch = "wasm32"))] +use std::sync::Condvar; +#[cfg(not(target_arch = "wasm32"))] use std::thread::{self, JoinHandle}; /// Default RAM frame cache ceiling (1 GiB ≈ 130 full-res 1080p frames or ~520 half-res frames). @@ -109,6 +117,7 @@ impl RamFrameCache { self.cache_epoch.load(Ordering::Acquire) } + #[cfg(not(target_arch = "wasm32"))] pub(crate) fn epoch_arc(&self) -> Arc { Arc::clone(&self.cache_epoch) } @@ -268,6 +277,7 @@ impl RamFrameCache { } /// Parameters for a background lookahead pre-fetch window. +#[cfg(not(target_arch = "wasm32"))] #[derive(Clone)] pub struct PrefetchJob { pub comp: Comp, @@ -280,6 +290,7 @@ pub struct PrefetchJob { pub use_proxy_clips: bool, } +#[cfg(not(target_arch = "wasm32"))] struct WorkerSlot { job: Option<(u64, PrefetchJob)>, shutdown: bool, @@ -290,6 +301,7 @@ struct WorkerSlot { /// /// Calling `request_lookahead` or `cancel` immediately increments an atomic generation /// counter so any in-flight lookahead loop aborts before evaluating another frame. +#[cfg(not(target_arch = "wasm32"))] pub struct RamPrefetcher { cache: RamFrameCache, cache_epoch: Arc, @@ -304,6 +316,7 @@ pub struct RamPrefetcher { worker: Option>, } +#[cfg(not(target_arch = "wasm32"))] impl RamPrefetcher { pub fn new(cache: RamFrameCache, worker_vram_budget_mb: u64) -> Self { Self::init(None, cache, worker_vram_budget_mb.max(128), 512) @@ -544,6 +557,7 @@ impl RamPrefetcher { } } +#[cfg(not(target_arch = "wasm32"))] impl Drop for RamPrefetcher { fn drop(&mut self) { self.generation.fetch_add(1, Ordering::AcqRel); @@ -574,7 +588,7 @@ impl Drop for RamPrefetcher { } } -#[cfg(test)] +#[cfg(all(test, not(target_arch = "wasm32")))] mod tests { use super::*; use std::time::{Duration, Instant}; diff --git a/crates/model/Cargo.toml b/crates/model/Cargo.toml index 7936f188d2ae34f13a6802b15a8f31191b8dcdba..a0f1038fdd1a6efcaf2dbbf1b88d05496e0a70c5 100644 --- a/crates/model/Cargo.toml +++ b/crates/model/Cargo.toml @@ -4,5 +4,5 @@ edition.workspace = true version.workspace = true publish.workspace = true -[dependencies] +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] mlua.workspace = true diff --git a/crates/model/src/expr.rs b/crates/model/src/expr.rs index f5de8d085f9ac4747bce6bd2d3176cd7ca7ff56b..e0e1599e7ab561b396ce436ba244d5f77b00b1a3 100644 --- a/crates/model/src/expr.rs +++ b/crates/model/src/expr.rs @@ -1,19 +1,8 @@ -//! Fusion SimpleExpression evaluator backed by `mlua` (Lua 5.4). +//! Fusion SimpleExpression evaluation: `mlua` (Lua 5.4) natively, a pure-Rust subset on `wasm32`. //! //! Supports Fusion globals (`time`, `iif`, `Point`, `Text`, `sin`/`cos`/`floor`/`ceil`/etc.) //! and `NodeName.ParamName` lookups without requiring full Fusion runtime scripting. -use mlua::{HookTriggers, Lua, LuaOptions, MultiValue, StdLib, Value, VmState}; -use std::collections::HashMap; -use std::sync::Arc; -use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; - -/// VM instructions one expression evaluation may execute before it is aborted. -const INSTRUCTION_BUDGET: u64 = 50_000; -/// Hook granularity; the budget is enforced in steps of this many instructions. -const HOOK_STEP: u32 = 1000; -const MEMORY_LIMIT: usize = 16 * 1024 * 1024; - /// An input readable from an expression. Text inputs surface as `{ Value = "..." }` tables that /// also stringify, matching Fusion's `Node.StyledText.Value`. #[derive(Clone, Debug, PartialEq)] @@ -22,316 +11,987 @@ pub enum ExprValue { Text(String), } -/// Expressions come from `.comp` files, so the VM is sandboxed: no `os`/`io`/`debug`/`package`, -/// no code loading, and bounded instructions and memory per evaluation. -pub struct ExprEngine { - lua: Lua, - instructions_used: Arc, - /// Latched once the budget is exceeded so every later hook call also errors. - aborted: Arc, -} +#[cfg(not(target_arch = "wasm32"))] +mod lua { + use super::ExprValue; + use mlua::{HookTriggers, Lua, LuaOptions, MultiValue, StdLib, Value, VmState}; + use std::collections::HashMap; + use std::sync::Arc; + use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; + + /// VM instructions one expression evaluation may execute before it is aborted. + const INSTRUCTION_BUDGET: u64 = 50_000; + /// Hook granularity; the budget is enforced in steps of this many instructions. + const HOOK_STEP: u32 = 1000; + const MEMORY_LIMIT: usize = 16 * 1024 * 1024; + + /// Expressions come from `.comp` files, so the VM is sandboxed: no `os`/`io`/`debug`/`package`, + /// no code loading, and bounded instructions and memory per evaluation. + pub struct ExprEngine { + lua: Lua, + instructions_used: Arc, + /// Latched once the budget is exceeded so every later hook call also errors. + aborted: Arc, + } + + impl Default for ExprEngine { + fn default() -> Self { + Self::new() + } + } + + impl ExprEngine { + pub fn new() -> Self { + let lua = Lua::new_with(StdLib::MATH | StdLib::STRING | StdLib::TABLE, LuaOptions::default()) + .expect("safe Lua stdlib subset loads"); + // Install Fusion SimpleExpression standard library into global scope. + let init = r#" + abs = math.abs + acos = math.acos + asin = math.asin + atan = math.atan + atan2 = math.atan + ceil = math.ceil + cos = math.cos + cosh = function(x) return (math.exp(x) + math.exp(-x)) * 0.5 end + deg = math.deg + exp = math.exp + floor = math.floor + fmod = math.fmod + log = math.log + log10 = function(x) return math.log(x, 10) end + max = math.max + min = math.min + mod = math.fmod + pi = math.pi + pow = function(a, b) return a ^ b end + rad = math.rad + sin = math.sin + sinh = function(x) return (math.exp(x) - math.exp(-x)) * 0.5 end + sqrt = math.sqrt + tan = math.tan + tanh = function(x) local e = math.exp(2*x); return (e - 1) / (e + 1) end + iif = function(cond, a, b) if cond and cond ~= 0 then return a else return b end end + Point = function(x, y) return { X = x or 0, Y = y or 0, [1] = x or 0, [2] = y or 0 } end + Text = function(s) return tostring(s or "") end + clamp = function(x, lo, hi) if x < lo then return lo elseif x > hi then return hi else return x end end + mix = function(a, b, t) return a + (b - a) * t end + "#; + let _ = lua.load(init).exec(); + + let globals = lua.globals(); + // Stdlib tables become write-protected proxies so no evaluation can alter them for the next. + let read_only = lua + .create_function(|_, _: MultiValue| -> mlua::Result<()> { + Err(mlua::Error::runtime("attempt to modify a read-only table")) + }) + .expect("function creates"); + for name in ["math", "string", "table"] { + let real: mlua::Table = globals.get(name).expect("stdlib table exists"); + let proxy = lua.create_table().expect("table creates"); + let mt = lua.create_table().expect("table creates"); + mt.set("__index", real).expect("table sets"); + mt.set("__newindex", read_only.clone()).expect("table sets"); + proxy.set_metatable(Some(mt)); + globals.set(name, proxy).expect("global sets"); + } + // `pcall`/`xpcall` would swallow the budget error; the rest reach shared tables or metatables. + for name in [ + "dofile", "loadfile", "load", "require", "collectgarbage", "os", "io", "debug", "package", + "pcall", "xpcall", "rawget", "rawset", "rawequal", "getmetatable", "setmetatable", "_G", + ] { + let _ = globals.set(name, Value::Nil); + } + + let instructions_used = Arc::new(AtomicU64::new(0)); + let aborted = Arc::new(AtomicBool::new(false)); + let counter = Arc::clone(&instructions_used); + let latch = Arc::clone(&aborted); + lua.set_hook(HookTriggers::new().every_nth_instruction(HOOK_STEP), move |_, _| { + if latch.load(Ordering::Relaxed) + || counter.fetch_add(u64::from(HOOK_STEP), Ordering::Relaxed) >= INSTRUCTION_BUDGET + { + latch.store(true, Ordering::Relaxed); + Err(mlua::Error::runtime("expression instruction budget exceeded")) + } else { + Ok(VmState::Continue) + } + }); + lua.set_memory_limit(MEMORY_LIMIT).expect("memory limit applies"); + + Self { lua, instructions_used, aborted } + } + + /// Evaluates `expr` in a fresh environment with a fresh instruction budget. + fn run( + &self, + expr: &str, + time: f64, + self_params: &HashMap, + self_points: &HashMap, + env_nodes: &HashMap>, + ) -> Option { + let env = self.build_env(time, self_params, self_points, env_nodes).ok()?; + self.instructions_used.store(0, Ordering::Relaxed); + self.aborted.store(false, Ordering::Relaxed); + self.lua.load(&Self::expr_chunk(expr)).set_environment(env).eval().ok() + } + + fn expr_chunk(expr: &str) -> String { + let trimmed = expr.trim_start(); + if let Some(body) = trimmed.strip_prefix(':') { + body.to_owned() + } else { + format!("return ({expr})") + } + } -impl Default for ExprEngine { - fn default() -> Self { - Self::new() + /// Evaluates a Fusion SimpleExpression returning a number. + /// `env_nodes` provides `node_name -> (param_name -> value)` and `self_params` provides + /// unqualified parameter names on the current node. + pub fn eval_number( + &self, + expr: &str, + time: f64, + self_params: &HashMap, + self_points: &HashMap, + env_nodes: &HashMap>, + ) -> Option { + let val = self.run(expr, time, self_params, self_points, env_nodes)?; + match val { + Value::Number(n) => Some(n), + Value::Integer(i) => Some(i as f64), + Value::Boolean(b) => Some(if b { 1.0 } else { 0.0 }), + Value::String(s) => s.to_str().ok()?.trim().parse::().ok(), + _ => None, + } + } + + /// Evaluates a Fusion SimpleExpression returning a 2D point `[x, y]`. + pub fn eval_point( + &self, + expr: &str, + time: f64, + self_params: &HashMap, + self_points: &HashMap, + env_nodes: &HashMap>, + ) -> Option<[f64; 2]> { + let val = self.run(expr, time, self_params, self_points, env_nodes)?; + if let Value::Table(t) = val { + let x = t.get::("X").or_else(|_| t.get::(1)).ok()?; + let y = t.get::("Y").or_else(|_| t.get::(2)).ok()?; + return Some([x, y]); + } + None + } + + /// Evaluates a Fusion SimpleExpression returning a string. + pub fn eval_string( + &self, + expr: &str, + time: f64, + self_params: &HashMap, + self_points: &HashMap, + env_nodes: &HashMap>, + ) -> Option { + let val = self.run(expr, time, self_params, self_points, env_nodes)?; + match val { + Value::String(s) => Some(s.to_str().ok()?.to_owned()), + Value::Number(n) => Some(format!("{n}")), + Value::Integer(i) => Some(format!("{i}")), + Value::Table(t) => t.get::("Value").ok(), + _ => None, + } + } + + fn build_env( + &self, + time: f64, + self_params: &HashMap, + self_points: &HashMap, + env_nodes: &HashMap>, + ) -> mlua::Result { + let env = self.lua.create_table()?; + let mt = self.lua.create_table()?; + mt.set("__index", self.lua.globals())?; + env.set_metatable(Some(mt)); + env.set("time", time)?; + env.set("comp", self.lua.create_table()?)?; + for (k, v) in self_params { + env.set(k.as_str(), *v)?; + } + for (k, p) in self_points { + let pt = self.lua.create_table()?; + pt.set("X", p[0])?; + pt.set("Y", p[1])?; + pt.set(1, p[0])?; + pt.set(2, p[1])?; + env.set(k.as_str(), pt)?; + } + // Missing node fields default to 0 so expressions don't nil-crash. + let zero_mt = self.lua.create_table()?; + zero_mt.set("__index", self.lua.create_function(|_, _args: MultiValue| Ok(0.0_f64))?)?; + let text_mt = self.lua.create_table()?; + text_mt.set("__tostring", self.lua.create_function(|_, this: mlua::Table| this.get::("Value"))?)?; + for (node_name, params) in env_nodes { + let nt = self.lua.create_table()?; + for (pk, pv) in params { + match pv { + ExprValue::Number(n) => nt.set(pk.as_str(), *n)?, + ExprValue::Text(s) => { + let text = self.lua.create_table()?; + text.set("Value", s.as_str())?; + text.set_metatable(Some(text_mt.clone())); + nt.set(pk.as_str(), text)?; + } + } + } + nt.set_metatable(Some(zero_mt.clone())); + env.set(node_name.as_str(), nt)?; + } + Ok(env) + } + } + + #[cfg(test)] + mod tests { + use super::*; + + fn num(expr: &str) -> Option { + let e = HashMap::new(); + ExprEngine::new().eval_number(expr, 2.0, &HashMap::new(), &HashMap::new(), &e) + } + + #[test] + fn fusion_expressions_still_evaluate() { + let v = num("time * 2 + math.sin(0.5)").unwrap(); + assert!((v - (4.0 + 0.5_f64.sin())).abs() < 1e-12); + assert_eq!(num("clamp(5, 0, 1)"), Some(1.0)); + assert_eq!(num(":local a = 3; return a * time"), Some(6.0)); + } + + #[test] + fn os_io_and_loaders_are_unavailable() { + let marker = std::env::temp_dir().join("fission_expr_sandbox_marker"); + let _ = std::fs::remove_file(&marker); + let cmd = format!("os.execute('touch {}')", marker.display()); + assert_eq!(num(&format!(":{cmd}; return 1")), None); + assert!(!marker.exists()); + for src in [ + "io.open('/etc/passwd')", + "require('os')", + "load('return 1')()", + "dofile('/etc/passwd')", + "debug.getinfo(1)", + "package.loaded", + "collectgarbage('count')", + ] { + assert_eq!(num(src), None, "{src}"); + } + } + + #[test] + fn runaway_loops_and_allocations_error_out() { + let engine = ExprEngine::new(); + let e = HashMap::new(); + let eval = |src: &str| engine.eval_number(src, 0.0, &HashMap::new(), &HashMap::new(), &e); + assert_eq!(eval(":while true do end"), None); + assert_eq!(eval(":local s = 'x'; while true do s = s .. s end"), None); + assert_eq!(eval("string.rep('x', 1e9) and 1"), None); + // Budget resets per evaluation, so the engine stays usable. + assert_eq!(eval("1 + 1"), Some(2.0)); + } + + #[test] + fn pcall_cannot_swallow_the_budget() { + let engine = ExprEngine::new(); + let e = HashMap::new(); + let eval = |src: &str| engine.eval_number(src, 0.0, &HashMap::new(), &HashMap::new(), &e); + let start = std::time::Instant::now(); + assert_eq!(eval(":while true do pcall(function() while true do end end) end"), None); + assert_eq!(eval(":while true do xpcall(function() while true do end end, print) end"), None); + assert!(start.elapsed() < std::time::Duration::from_millis(50), "{:?}", start.elapsed()); + assert_eq!(eval("1 + 1"), Some(2.0)); + } + + #[test] + fn evaluations_cannot_mutate_shared_state() { + let engine = ExprEngine::new(); + let e = HashMap::new(); + let eval = |src: &str| engine.eval_number(src, 0.0, &HashMap::new(), &HashMap::new(), &e); + for src in [ + ":math.floor = function() return 42 end; return 1", + ":string.upper = function() return 42 end; return 1", + ":table.insert = nil; return 1", + ":_G.leak = 1; return 1", + ":getmetatable('').__index.upper = nil; return 1", + ":setmetatable(math, nil); return 1", + ] { + assert_eq!(eval(src), None, "{src}"); + } + assert_eq!(eval(":floor = function() return 42 end; return floor(1.5)"), Some(42.0)); + assert_eq!(eval("floor(1.5)"), Some(1.0)); + assert_eq!(eval("math.floor(1.5)"), Some(1.0)); + assert_eq!(eval("leak"), None); + let upper = engine.eval_string("('a'):upper()", 0.0, &HashMap::new(), &HashMap::new(), &e); + assert_eq!(upper.as_deref(), Some("A")); + assert_eq!(eval("string.len('abc') + select('#', table.unpack({1, 2}))"), Some(5.0)); + } } } -impl ExprEngine { - pub fn new() -> Self { - let lua = Lua::new_with(StdLib::MATH | StdLib::STRING | StdLib::TABLE, LuaOptions::default()) - .expect("safe Lua stdlib subset loads"); - // Install Fusion SimpleExpression standard library into global scope. - let init = r#" - abs = math.abs - acos = math.acos - asin = math.asin - atan = math.atan - atan2 = math.atan - ceil = math.ceil - cos = math.cos - cosh = function(x) return (math.exp(x) + math.exp(-x)) * 0.5 end - deg = math.deg - exp = math.exp - floor = math.floor - fmod = math.fmod - log = math.log - log10 = function(x) return math.log(x, 10) end - max = math.max - min = math.min - mod = math.fmod - pi = math.pi - pow = function(a, b) return a ^ b end - rad = math.rad - sin = math.sin - sinh = function(x) return (math.exp(x) - math.exp(-x)) * 0.5 end - sqrt = math.sqrt - tan = math.tan - tanh = function(x) local e = math.exp(2*x); return (e - 1) / (e + 1) end - iif = function(cond, a, b) if cond and cond ~= 0 then return a else return b end end - Point = function(x, y) return { X = x or 0, Y = y or 0, [1] = x or 0, [2] = y or 0 } end - Text = function(s) return tostring(s or "") end - clamp = function(x, lo, hi) if x < lo then return lo elseif x > hi then return hi else return x end end - mix = function(a, b, t) return a + (b - a) * t end - "#; - let _ = lua.load(init).exec(); - - let globals = lua.globals(); - // Stdlib tables become write-protected proxies so no evaluation can alter them for the next. - let read_only = lua - .create_function(|_, _: MultiValue| -> mlua::Result<()> { - Err(mlua::Error::runtime("attempt to modify a read-only table")) - }) - .expect("function creates"); - for name in ["math", "string", "table"] { - let real: mlua::Table = globals.get(name).expect("stdlib table exists"); - let proxy = lua.create_table().expect("table creates"); - let mt = lua.create_table().expect("table creates"); - mt.set("__index", real).expect("table sets"); - mt.set("__newindex", read_only.clone()).expect("table sets"); - proxy.set_metatable(Some(mt)); - globals.set(name, proxy).expect("global sets"); - } - // `pcall`/`xpcall` would swallow the budget error; the rest reach shared tables or metatables. - for name in [ - "dofile", "loadfile", "load", "require", "collectgarbage", "os", "io", "debug", "package", - "pcall", "xpcall", "rawget", "rawset", "rawequal", "getmetatable", "setmetatable", "_G", - ] { - let _ = globals.set(name, Value::Nil); - } - - let instructions_used = Arc::new(AtomicU64::new(0)); - let aborted = Arc::new(AtomicBool::new(false)); - let counter = Arc::clone(&instructions_used); - let latch = Arc::clone(&aborted); - lua.set_hook(HookTriggers::new().every_nth_instruction(HOOK_STEP), move |_, _| { - if latch.load(Ordering::Relaxed) - || counter.fetch_add(u64::from(HOOK_STEP), Ordering::Relaxed) >= INSTRUCTION_BUDGET - { - latch.store(true, Ordering::Relaxed); - Err(mlua::Error::runtime("expression instruction budget exceeded")) +#[cfg(not(target_arch = "wasm32"))] +pub use lua::ExprEngine; +#[cfg(target_arch = "wasm32")] +pub use pure::ExprEngine; + +/// Lua-subset evaluator for targets without a C toolchain: literals, `+ - * / // % ^ ..`, +/// comparisons, `and`/`or`/`not`, calls, `a.b` / `a[b]`, the Fusion globals and `math.*`. +/// Statement bodies (`:local x = ...`) and method calls are unsupported and evaluate to `None`. +#[cfg(any(target_arch = "wasm32", test))] +mod pure { + use super::ExprValue; + use std::collections::HashMap; + + const MAX_DEPTH: usize = 64; + const MATH_FNS: &[&str] = &[ + "abs", "acos", "asin", "atan", "ceil", "cos", "deg", "exp", "floor", "fmod", "log", "max", "min", "rad", + "sin", "sqrt", "tan", + ]; + const GLOBAL_FNS: &[&str] = &[ + "atan2", "clamp", "cosh", "iif", "log10", "mix", "mod", "pow", "Point", "sinh", "tanh", "Text", + "tonumber", "tostring", + ]; + + #[derive(Clone, Debug, PartialEq)] + enum Tok { + Num(f64), + Str(String), + Name(String), + Op(&'static str), + } + + fn lex(src: &str) -> Option> { + const OPS: &[&str] = &[ + "..", "==", "~=", "<=", ">=", "//", "+", "-", "*", "/", "%", "^", "<", ">", "(", ")", "[", "]", ",", ".", + ]; + let chars: Vec = src.chars().collect(); + let mut toks = Vec::new(); + let mut i = 0; + while i < chars.len() { + let c = chars[i]; + if c.is_whitespace() { + i += 1; + } else if c.is_ascii_digit() || (c == '.' && chars.get(i + 1).is_some_and(char::is_ascii_digit)) { + let start = i; + if c == '0' && matches!(chars.get(i + 1), Some('x' | 'X')) { + i += 2; + while chars.get(i).is_some_and(char::is_ascii_hexdigit) { + i += 1; + } + let digits: String = chars[start + 2..i].iter().collect(); + toks.push(Tok::Num(u64::from_str_radix(&digits, 16).ok()? as f64)); + continue; + } + while chars.get(i).is_some_and(char::is_ascii_digit) { + i += 1; + } + if chars.get(i) == Some(&'.') && chars.get(i + 1) != Some(&'.') { + i += 1; + while chars.get(i).is_some_and(char::is_ascii_digit) { + i += 1; + } + } + if matches!(chars.get(i), Some('e' | 'E')) { + i += 1; + if matches!(chars.get(i), Some('+' | '-')) { + i += 1; + } + while chars.get(i).is_some_and(char::is_ascii_digit) { + i += 1; + } + } + toks.push(Tok::Num(chars[start..i].iter().collect::().parse().ok()?)); + } else if c.is_alphabetic() || c == '_' { + let start = i; + while chars.get(i).is_some_and(|c| c.is_alphanumeric() || *c == '_') { + i += 1; + } + toks.push(Tok::Name(chars[start..i].iter().collect())); + } else if c == '"' || c == '\'' { + let mut s = String::new(); + i += 1; + loop { + match *chars.get(i)? { + q if q == c => break, + '\\' => { + i += 1; + s.push(match *chars.get(i)? { + 'n' => '\n', + 't' => '\t', + other => other, + }); + } + other => s.push(other), + } + i += 1; + } + i += 1; + toks.push(Tok::Str(s)); } else { - Ok(VmState::Continue) + let rest: String = chars[i..chars.len().min(i + 2)].iter().collect(); + let op = OPS.iter().find(|op| rest.starts_with(**op))?; + i += op.len(); + toks.push(Tok::Op(op)); } - }); - lua.set_memory_limit(MEMORY_LIMIT).expect("memory limit applies"); + } + Some(toks) + } - Self { lua, instructions_used, aborted } + #[derive(Debug)] + enum Ast { + Nil, + Bool(bool), + Num(f64), + Str(String), + Name(String), + Index(Box, Box), + Call(Box, Vec), + Neg(Box), + Not(Box), + Bin(&'static str, Box, Box), } - /// Evaluates `expr` in a fresh environment with a fresh instruction budget. - fn run( - &self, - expr: &str, - time: f64, - self_params: &HashMap, - self_points: &HashMap, - env_nodes: &HashMap>, - ) -> Option { - let env = self.build_env(time, self_params, self_points, env_nodes).ok()?; - self.instructions_used.store(0, Ordering::Relaxed); - self.aborted.store(false, Ordering::Relaxed); - self.lua.load(&Self::expr_chunk(expr)).set_environment(env).eval().ok() - } - - fn expr_chunk(expr: &str) -> String { - let trimmed = expr.trim_start(); - if let Some(body) = trimmed.strip_prefix(':') { - body.to_owned() - } else { - format!("return ({expr})") - } - } - - /// Evaluates a Fusion SimpleExpression returning a number. - /// `env_nodes` provides `node_name -> (param_name -> value)` and `self_params` provides - /// unqualified parameter names on the current node. - pub fn eval_number( - &self, - expr: &str, - time: f64, - self_params: &HashMap, - self_points: &HashMap, - env_nodes: &HashMap>, - ) -> Option { - let val = self.run(expr, time, self_params, self_points, env_nodes)?; - match val { - Value::Number(n) => Some(n), - Value::Integer(i) => Some(i as f64), - Value::Boolean(b) => Some(if b { 1.0 } else { 0.0 }), - Value::String(s) => s.to_str().ok()?.trim().parse::().ok(), - _ => None, + struct Parser { + toks: Vec, + pos: usize, + depth: usize, + } + + impl Parser { + fn peek(&self) -> Option<&Tok> { + self.toks.get(self.pos) + } + + fn eat_op(&mut self, op: &str) -> bool { + let hit = matches!(self.peek(), Some(Tok::Op(o)) if *o == op); + self.pos += usize::from(hit); + hit + } + + fn binary_op(&self) -> Option<(&'static str, u8, u8)> { + let op = match self.peek()? { + Tok::Op(op) => *op, + Tok::Name(n) if n == "and" => "and", + Tok::Name(n) if n == "or" => "or", + _ => return None, + }; + // Lua precedence, lowest first; `..` and `^` are right associative. + let (left, right) = match op { + "or" => (1, 2), + "and" => (3, 4), + "<" | ">" | "<=" | ">=" | "==" | "~=" => (5, 6), + ".." => (9, 8), + "+" | "-" => (10, 11), + "*" | "/" | "//" | "%" => (12, 13), + "^" => (16, 15), + _ => return None, + }; + Some((op, left, right)) + } + + fn expr(&mut self, min_bp: u8) -> Option { + self.depth += 1; + let ast = if self.depth > MAX_DEPTH { None } else { self.binary(min_bp) }; + self.depth -= 1; + ast + } + + fn binary(&mut self, min_bp: u8) -> Option { + let mut lhs = self.unary()?; + while let Some((op, left, right)) = self.binary_op() { + if left < min_bp { + break; + } + self.pos += 1; + let rhs = self.expr(right)?; + lhs = Ast::Bin(op, Box::new(lhs), Box::new(rhs)); + } + Some(lhs) + } + + fn unary(&mut self) -> Option { + if self.eat_op("-") { + return Some(Ast::Neg(Box::new(self.expr(14)?))); + } + if matches!(self.peek(), Some(Tok::Name(n)) if n == "not") { + self.pos += 1; + return Some(Ast::Not(Box::new(self.expr(14)?))); + } + self.postfix() + } + + fn postfix(&mut self) -> Option { + let mut node = match self.toks.get(self.pos)?.clone() { + Tok::Num(n) => Ast::Num(n), + Tok::Str(s) => Ast::Str(s), + Tok::Name(n) => match n.as_str() { + "nil" => Ast::Nil, + "true" => Ast::Bool(true), + "false" => Ast::Bool(false), + "and" | "or" | "not" => return None, + _ => Ast::Name(n), + }, + Tok::Op("(") => { + self.pos += 1; + let inner = self.expr(0)?; + if !matches!(self.peek(), Some(Tok::Op(")"))) { + return None; + } + inner + } + Tok::Op(_) => return None, + }; + self.pos += 1; + loop { + if self.eat_op(".") { + let Some(Tok::Name(key)) = self.peek().cloned() else { return None }; + self.pos += 1; + node = Ast::Index(Box::new(node), Box::new(Ast::Str(key))); + } else if self.eat_op("[") { + let key = self.expr(0)?; + if !self.eat_op("]") { + return None; + } + node = Ast::Index(Box::new(node), Box::new(key)); + } else if self.eat_op("(") { + let mut args = Vec::new(); + if !self.eat_op(")") { + loop { + args.push(self.expr(0)?); + if self.eat_op(")") { + break; + } + if !self.eat_op(",") { + return None; + } + } + } + node = Ast::Call(Box::new(node), args); + } else { + return Some(node); + } + } } } - /// Evaluates a Fusion SimpleExpression returning a 2D point `[x, y]`. - pub fn eval_point( - &self, - expr: &str, - time: f64, - self_params: &HashMap, - self_points: &HashMap, - env_nodes: &HashMap>, - ) -> Option<[f64; 2]> { - let val = self.run(expr, time, self_params, self_points, env_nodes)?; - if let Value::Table(t) = val { - let x = t.get::("X").or_else(|_| t.get::(1)).ok()?; - let y = t.get::("Y").or_else(|_| t.get::(2)).ok()?; - return Some([x, y]); - } - None - } - - /// Evaluates a Fusion SimpleExpression returning a string. - pub fn eval_string( - &self, - expr: &str, - time: f64, - self_params: &HashMap, - self_points: &HashMap, - env_nodes: &HashMap>, - ) -> Option { - let val = self.run(expr, time, self_params, self_points, env_nodes)?; - match val { - Value::String(s) => Some(s.to_str().ok()?.to_owned()), - Value::Number(n) => Some(format!("{n}")), - Value::Integer(i) => Some(format!("{i}")), - Value::Table(t) => t.get::("Value").ok(), - _ => None, + #[derive(Clone, Debug, PartialEq)] + enum Val<'a> { + Nil, + Bool(bool), + Num(f64), + Str(String), + Point([f64; 2]), + /// `{ Value = "..." }` that also stringifies. + Text(String), + Node(&'a HashMap), + Math, + Func(&'static str), + } + + impl Val<'_> { + fn truthy(&self) -> bool { + !matches!(self, Val::Nil | Val::Bool(false)) + } + + /// Lua's arithmetic coercion: numbers and numeric strings. + fn num(&self) -> Option { + match self { + Val::Num(n) => Some(*n), + Val::Str(s) => s.trim().parse().ok(), + _ => None, + } + } + + fn text(&self) -> Option { + match self { + Val::Num(n) => Some(format!("{n}")), + Val::Str(s) | Val::Text(s) => Some(s.clone()), + _ => None, + } } } - fn build_env( - &self, + struct Scope<'a> { time: f64, - self_params: &HashMap, - self_points: &HashMap, - env_nodes: &HashMap>, - ) -> mlua::Result { - let env = self.lua.create_table()?; - let mt = self.lua.create_table()?; - mt.set("__index", self.lua.globals())?; - env.set_metatable(Some(mt)); - env.set("time", time)?; - env.set("comp", self.lua.create_table()?)?; - for (k, v) in self_params { - env.set(k.as_str(), *v)?; - } - for (k, p) in self_points { - let pt = self.lua.create_table()?; - pt.set("X", p[0])?; - pt.set("Y", p[1])?; - pt.set(1, p[0])?; - pt.set(2, p[1])?; - env.set(k.as_str(), pt)?; - } - // Missing node fields default to 0 so expressions don't nil-crash. - let zero_mt = self.lua.create_table()?; - zero_mt.set("__index", self.lua.create_function(|_, _args: MultiValue| Ok(0.0_f64))?)?; - let text_mt = self.lua.create_table()?; - text_mt.set("__tostring", self.lua.create_function(|_, this: mlua::Table| this.get::("Value"))?)?; - for (node_name, params) in env_nodes { - let nt = self.lua.create_table()?; - for (pk, pv) in params { - match pv { - ExprValue::Number(n) => nt.set(pk.as_str(), *n)?, - ExprValue::Text(s) => { - let text = self.lua.create_table()?; - text.set("Value", s.as_str())?; - text.set_metatable(Some(text_mt.clone())); - nt.set(pk.as_str(), text)?; - } + params: &'a HashMap, + points: &'a HashMap, + nodes: &'a HashMap>, + } + + impl<'a> Scope<'a> { + /// Nodes shadow points shadow params shadow `time` shadow the stdlib, as in the Lua env. + fn name(&self, name: &str) -> Val<'a> { + if let Some(node) = self.nodes.get(name) { + Val::Node(node) + } else if let Some(p) = self.points.get(name) { + Val::Point(*p) + } else if let Some(n) = self.params.get(name) { + Val::Num(*n) + } else if name == "time" { + Val::Num(self.time) + } else if name == "pi" { + Val::Num(std::f64::consts::PI) + } else if name == "math" { + Val::Math + } else if let Some(f) = MATH_FNS.iter().chain(GLOBAL_FNS).find(|f| **f == name) { + Val::Func(f) + } else { + Val::Nil + } + } + + fn eval(&self, ast: &Ast) -> Option> { + Some(match ast { + Ast::Nil => Val::Nil, + Ast::Bool(b) => Val::Bool(*b), + Ast::Num(n) => Val::Num(*n), + Ast::Str(s) => Val::Str(s.clone()), + Ast::Name(n) => self.name(n), + Ast::Neg(a) => Val::Num(-self.eval(a)?.num()?), + Ast::Not(a) => Val::Bool(!self.eval(a)?.truthy()), + Ast::Index(base, key) => index(self.eval(base)?, self.eval(key)?)?, + Ast::Call(callee, args) => { + let Val::Func(name) = self.eval(callee)? else { return None }; + let args = args.iter().map(|a| self.eval(a)).collect::>>()?; + call(name, &args)? + } + Ast::Bin("and", a, b) => { + let a = self.eval(a)?; + if a.truthy() { self.eval(b)? } else { a } } + Ast::Bin("or", a, b) => { + let a = self.eval(a)?; + if a.truthy() { a } else { self.eval(b)? } + } + Ast::Bin(op, a, b) => binary(op, self.eval(a)?, self.eval(b)?)?, + }) + } + } + + fn index<'a>(base: Val<'a>, key: Val<'a>) -> Option> { + Some(match (base, key) { + (Val::Node(fields), key) => match key { + Val::Str(k) => match fields.get(&k) { + Some(ExprValue::Number(n)) => Val::Num(*n), + Some(ExprValue::Text(s)) => Val::Text(s.clone()), + None => Val::Num(0.0), + }, + _ => Val::Num(0.0), + }, + (Val::Text(s), Val::Str(k)) if k == "Value" => Val::Str(s), + (Val::Text(_), _) => Val::Nil, + (Val::Point(p), Val::Str(k)) if k == "X" => Val::Num(p[0]), + (Val::Point(p), Val::Str(k)) if k == "Y" => Val::Num(p[1]), + (Val::Point(p), Val::Num(1.0)) => Val::Num(p[0]), + (Val::Point(p), Val::Num(2.0)) => Val::Num(p[1]), + (Val::Point(_), _) => Val::Nil, + (Val::Math, Val::Str(k)) => match k.as_str() { + "pi" => Val::Num(std::f64::consts::PI), + "huge" => Val::Num(f64::INFINITY), + _ => MATH_FNS.iter().find(|f| **f == k).map_or(Val::Nil, |f| Val::Func(f)), + }, + _ => return None, + }) + } + + fn binary<'a>(op: &str, a: Val<'a>, b: Val<'a>) -> Option> { + use std::cmp::Ordering; + let ordering = |a: &Val, b: &Val| match (a, b) { + (Val::Num(a), Val::Num(b)) => a.partial_cmp(b).map(Some), + (Val::Str(a), Val::Str(b)) => Some(Some(a.cmp(b))), + _ => None, + }; + Some(match op { + "==" => Val::Bool(a == b), + "~=" => Val::Bool(a != b), + "<" => Val::Bool(ordering(&a, &b)?.is_some_and(|o| o == Ordering::Less)), + "<=" => Val::Bool(ordering(&a, &b)?.is_some_and(|o| o != Ordering::Greater)), + ">" => Val::Bool(ordering(&a, &b)?.is_some_and(|o| o == Ordering::Greater)), + ">=" => Val::Bool(ordering(&a, &b)?.is_some_and(|o| o != Ordering::Less)), + ".." => Val::Str(a.text()? + &b.text()?), + _ => { + let (a, b) = (a.num()?, b.num()?); + Val::Num(match op { + "+" => a + b, + "-" => a - b, + "*" => a * b, + "/" => a / b, + "//" => (a / b).floor(), + "%" => a - (a / b).floor() * b, + "^" => a.powf(b), + _ => return None, + }) + } + }) + } + + fn call<'a>(name: &str, args: &[Val<'a>]) -> Option> { + let arg = |i: usize| args.get(i).and_then(Val::num); + let unary: Option f64> = match name { + "abs" => Some(f64::abs), + "acos" => Some(f64::acos), + "asin" => Some(f64::asin), + "ceil" => Some(f64::ceil), + "cos" => Some(f64::cos), + "cosh" => Some(f64::cosh), + "deg" => Some(f64::to_degrees), + "exp" => Some(f64::exp), + "floor" => Some(f64::floor), + "log10" => Some(f64::log10), + "rad" => Some(f64::to_radians), + "sin" => Some(f64::sin), + "sinh" => Some(f64::sinh), + "sqrt" => Some(f64::sqrt), + "tan" => Some(f64::tan), + "tanh" => Some(f64::tanh), + _ => None, + }; + if let Some(f) = unary { + return Some(Val::Num(f(arg(0)?))); + } + Some(match name { + "atan" | "atan2" => Val::Num(match arg(1) { + Some(x) => arg(0)?.atan2(x), + None => arg(0)?.atan(), + }), + "fmod" | "mod" => Val::Num(arg(0)? % arg(1)?), + "pow" => Val::Num(arg(0)?.powf(arg(1)?)), + "log" => Val::Num(match arg(1) { + Some(2.0) => arg(0)?.log2(), + Some(10.0) => arg(0)?.log10(), + Some(base) => arg(0)?.ln() / base.ln(), + None => arg(0)?.ln(), + }), + "max" | "min" => { + let mut nums = (0..args.len()).map(arg); + let first = nums.next()??; + let pick = if name == "max" { f64::max } else { f64::min }; + Val::Num(nums.try_fold(first, |acc, n| n.map(|n| pick(acc, n)))?) + } + "iif" => { + let cond = args.first()?; + let pass = cond.truthy() && cond.num() != Some(0.0); + args.get(if pass { 1 } else { 2 }).cloned().unwrap_or(Val::Nil) + } + "clamp" => { + let (x, lo, hi) = (arg(0)?, arg(1)?, arg(2)?); + Val::Num(if x < lo { lo } else if x > hi { hi } else { x }) + } + "mix" => Val::Num(arg(0)? + (arg(1)? - arg(0)?) * arg(2)?), + "Point" => Val::Point([arg(0).unwrap_or(0.0), arg(1).unwrap_or(0.0)]), + "Text" | "tostring" => Val::Str(args.first().map_or(Some(String::new()), Val::text)?), + "tonumber" => args.first()?.num().map_or(Val::Nil, Val::Num), + _ => return None, + }) + } + + #[derive(Default)] + pub struct ExprEngine; + + impl ExprEngine { + pub fn new() -> Self { + Self + } + + fn run( + &self, + expr: &str, + time: f64, + self_params: &HashMap, + self_points: &HashMap, + env_nodes: &HashMap>, + read: impl FnOnce(Val) -> Option, + ) -> Option { + let body = match expr.trim_start().strip_prefix(':') { + Some(stmt) => stmt.trim_start().strip_prefix("return ")?, + None => expr, + }; + let mut parser = Parser { toks: lex(body)?, pos: 0, depth: 0 }; + let ast = parser.expr(0)?; + if parser.pos != parser.toks.len() { + return None; + } + let scope = Scope { time, params: self_params, points: self_points, nodes: env_nodes }; + read(scope.eval(&ast)?) + } + + pub fn eval_number( + &self, + expr: &str, + time: f64, + self_params: &HashMap, + self_points: &HashMap, + env_nodes: &HashMap>, + ) -> Option { + self.run(expr, time, self_params, self_points, env_nodes, |v| match v { + Val::Bool(b) => Some(f64::from(b)), + other => other.num(), + }) + } + + pub fn eval_point( + &self, + expr: &str, + time: f64, + self_params: &HashMap, + self_points: &HashMap, + env_nodes: &HashMap>, + ) -> Option<[f64; 2]> { + self.run(expr, time, self_params, self_points, env_nodes, |v| match v { + Val::Point(p) => Some(p), + _ => None, + }) + } + + pub fn eval_string( + &self, + expr: &str, + time: f64, + self_params: &HashMap, + self_points: &HashMap, + env_nodes: &HashMap>, + ) -> Option { + self.run(expr, time, self_params, self_points, env_nodes, |v| v.text()) + } + } + + #[cfg(test)] + mod tests { + use super::*; + + fn nodes() -> HashMap> { + HashMap::from([( + "Ctl".to_owned(), + HashMap::from([ + ("Size".to_owned(), ExprValue::Number(0.25)), + ("StyledText".to_owned(), ExprValue::Text("hi".to_owned())), + ]), + )]) + } + + fn num(expr: &str, time: f64) -> Option { + let params = HashMap::from([("Width".to_owned(), 8.0)]); + let points = HashMap::from([("Center".to_owned(), [0.5, 0.25])]); + ExprEngine::new().eval_number(expr, time, ¶ms, &points, &nodes()) + } + + #[test] + fn falling_comp_expressions() { + assert_eq!(num("floor(time/3)*3", 7.0), Some(6.0)); + assert_eq!(num("floor(time/2)/4", 9.0), Some(1.0)); + assert_eq!(num("floor(time/5)*42", 11.0), Some(84.0)); + assert_eq!(num("math.floor(time / 5) * 42", 11.0), Some(84.0)); + } + + #[test] + fn precedence_and_associativity() { + assert_eq!(num("-2^2", 0.0), Some(-4.0)); + assert_eq!(num("2^3^2", 0.0), Some(512.0)); + assert_eq!(num("2^-1", 0.0), Some(0.5)); + assert_eq!(num("1 + 2 * 3 - 4 / 2", 0.0), Some(5.0)); + assert_eq!(num("-7 % 3", 0.0), Some(2.0)); + assert_eq!(num("7 // 2", 0.0), Some(3.0)); + assert_eq!(num("1 .. 2 + 1", 0.0), Some(13.0)); + } + + #[test] + fn logic_and_ternaries() { + assert_eq!(num("iif(time > 1, 10, 20)", 2.0), Some(10.0)); + assert_eq!(num("iif(0, 10, 20)", 2.0), Some(20.0)); + assert_eq!(num("time > 1 and 5 or 6", 0.0), Some(6.0)); + assert_eq!(num("nil or 3", 0.0), Some(3.0)); + assert_eq!(num("not (1 == 1)", 0.0), Some(0.0)); + assert_eq!(num("clamp(5, 0, 1) + min(3, 2, 9) + max(1, 4)", 0.0), Some(7.0)); + assert_eq!(num("mix(10, 20, 0.5)", 0.0), Some(15.0)); + } + + #[test] + fn scope_lookups() { + assert_eq!(num("Width * 2", 0.0), Some(16.0)); + assert_eq!(num("Center.X + Center[2]", 0.0), Some(0.75)); + assert_eq!(num("Ctl.Size", 0.0), Some(0.25)); + assert_eq!(num("Ctl.Missing", 0.0), Some(0.0)); + assert_eq!(num("Nope.Size", 0.0), None); + assert_eq!(num("sin(pi / 2) + atan(1, 1) * 0", 0.0), Some(1.0)); + } + + #[test] + fn points_and_strings() { + let e = ExprEngine::new(); + let (p, q, n) = (HashMap::new(), HashMap::new(), nodes()); + assert_eq!(e.eval_point("Point(time, 0.5)", 2.0, &p, &q, &n), Some([2.0, 0.5])); + assert_eq!(e.eval_string("Ctl.StyledText.Value .. '!'", 0.0, &p, &q, &n).as_deref(), Some("hi!")); + assert_eq!(e.eval_string("Ctl.StyledText", 0.0, &p, &q, &n).as_deref(), Some("hi")); + assert_eq!(e.eval_string("Text('f' .. time)", 3.0, &p, &q, &n).as_deref(), Some("f3")); + assert_eq!(e.eval_string("time", 2.5, &p, &q, &n).as_deref(), Some("2.5")); + } + + #[test] + fn unsupported_and_malformed_input_is_none() { + for src in ["", "1 +", "(1", "1 2", "foo(1)", "'a':upper()", ":local a = 1; return a", "1 @ 2", "'abc", "{}"] { + assert_eq!(num(src, 0.0), None, "{src:?}"); } - nt.set_metatable(Some(zero_mt.clone())); - env.set(node_name.as_str(), nt)?; + assert_eq!(num(":return time * 2", 2.0), Some(4.0)); + assert_eq!(num(&"(".repeat(200), 0.0), None); } - Ok(env) } } #[cfg(test)] -mod tests { - use super::*; - - fn num(expr: &str) -> Option { - let e = HashMap::new(); - ExprEngine::new().eval_number(expr, 2.0, &HashMap::new(), &HashMap::new(), &e) - } - - #[test] - fn fusion_expressions_still_evaluate() { - let v = num("time * 2 + math.sin(0.5)").unwrap(); - assert!((v - (4.0 + 0.5_f64.sin())).abs() < 1e-12); - assert_eq!(num("clamp(5, 0, 1)"), Some(1.0)); - assert_eq!(num(":local a = 3; return a * time"), Some(6.0)); - } - - #[test] - fn os_io_and_loaders_are_unavailable() { - let marker = std::env::temp_dir().join("fission_expr_sandbox_marker"); - let _ = std::fs::remove_file(&marker); - let cmd = format!("os.execute('touch {}')", marker.display()); - assert_eq!(num(&format!(":{cmd}; return 1")), None); - assert!(!marker.exists()); - for src in [ - "io.open('/etc/passwd')", - "require('os')", - "load('return 1')()", - "dofile('/etc/passwd')", - "debug.getinfo(1)", - "package.loaded", - "collectgarbage('count')", - ] { - assert_eq!(num(src), None, "{src}"); - } - } - - #[test] - fn runaway_loops_and_allocations_error_out() { - let engine = ExprEngine::new(); - let e = HashMap::new(); - let eval = |src: &str| engine.eval_number(src, 0.0, &HashMap::new(), &HashMap::new(), &e); - assert_eq!(eval(":while true do end"), None); - assert_eq!(eval(":local s = 'x'; while true do s = s .. s end"), None); - assert_eq!(eval("string.rep('x', 1e9) and 1"), None); - // Budget resets per evaluation, so the engine stays usable. - assert_eq!(eval("1 + 1"), Some(2.0)); - } - - #[test] - fn pcall_cannot_swallow_the_budget() { - let engine = ExprEngine::new(); - let e = HashMap::new(); - let eval = |src: &str| engine.eval_number(src, 0.0, &HashMap::new(), &HashMap::new(), &e); - let start = std::time::Instant::now(); - assert_eq!(eval(":while true do pcall(function() while true do end end) end"), None); - assert_eq!(eval(":while true do xpcall(function() while true do end end, print) end"), None); - assert!(start.elapsed() < std::time::Duration::from_millis(50), "{:?}", start.elapsed()); - assert_eq!(eval("1 + 1"), Some(2.0)); - } +mod parity { + use super::{ExprEngine, ExprValue, pure}; + use std::collections::HashMap; #[test] - fn evaluations_cannot_mutate_shared_state() { - let engine = ExprEngine::new(); - let e = HashMap::new(); - let eval = |src: &str| engine.eval_number(src, 0.0, &HashMap::new(), &HashMap::new(), &e); - for src in [ - ":math.floor = function() return 42 end; return 1", - ":string.upper = function() return 42 end; return 1", - ":table.insert = nil; return 1", - ":_G.leak = 1; return 1", - ":getmetatable('').__index.upper = nil; return 1", - ":setmetatable(math, nil); return 1", - ] { - assert_eq!(eval(src), None, "{src}"); + fn pure_matches_lua_on_shared_subset() { + let params = HashMap::from([("Width".to_owned(), 8.0)]); + let points = HashMap::from([("Center".to_owned(), [0.5, 0.25])]); + let nodes = HashMap::from([( + "Ctl".to_owned(), + HashMap::from([("Size".to_owned(), ExprValue::Number(0.25))]), + )]); + let (lua, pure) = (ExprEngine::new(), pure::ExprEngine::new()); + for time in [0.0, 2.5, 7.0, 11.0] { + for src in [ + "floor(time/3)*3", + "floor(time/2)/4", + "floor(time/5)*42", + "time * 2 + math.sin(0.5)", + "-2^2", + "2^3^2", + "-7 % 3", + "7 // 2", + "iif(time > 3, 10, 20)", + "time > 3 and 5 or 6", + "clamp(time, 1, 4) + mix(1, 3, 0.5)", + "Width / 3 + Center.X + Center[2] + Ctl.Size + Ctl.Missing", + "atan(1, 2) + atan2(1, 2) + log(8, 2) + log10(100) + fmod(-7, 3) + pow(2, 0.5)", + "max(1, time, 3) + min(time, 9) + abs(-time) + ceil(time) + sqrt(time)", + "cosh(time) + sinh(time) + tanh(time) + deg(1) + rad(90)", + "time ~= 2.5", + "'10' + 1", + "Nope.Size", + "1 +", + ] { + let args = (src, time, ¶ms, &points, &nodes); + let l = lua.eval_number(args.0, args.1, args.2, args.3, args.4); + let p = pure.eval_number(args.0, args.1, args.2, args.3, args.4); + match (l, p) { + (Some(l), Some(p)) => assert!((l - p).abs() < 1e-9 || (l.is_nan() && p.is_nan()), "{src} @ {time}: {l} vs {p}"), + _ => assert_eq!(l, p, "{src} @ {time}"), + } + } } - assert_eq!(eval(":floor = function() return 42 end; return floor(1.5)"), Some(42.0)); - assert_eq!(eval("floor(1.5)"), Some(1.0)); - assert_eq!(eval("math.floor(1.5)"), Some(1.0)); - assert_eq!(eval("leak"), None); - let upper = engine.eval_string("('a'):upper()", 0.0, &HashMap::new(), &HashMap::new(), &e); - assert_eq!(upper.as_deref(), Some("A")); - assert_eq!(eval("string.len('abc') + select('#', table.unpack({1, 2}))"), Some(5.0)); } } diff --git a/crates/web/.gitignore b/crates/web/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4f96631daba2b55f514c8ae422bd7742e5d97e51 --- /dev/null +++ b/crates/web/.gitignore @@ -0,0 +1,2 @@ +/target +/dist diff --git a/crates/web/Cargo.lock b/crates/web/Cargo.lock new file mode 100644 index 0000000000000000000000000000000000000000..073ca1e4c881d6d15710cac96190e641095f84a0 --- /dev/null +++ b/crates/web/Cargo.lock @@ -0,0 +1,2605 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57b212daf2e827b1ccdd778b7eb48ba433e58cb0e4f27b43cd6b7a608425a014" + +[[package]] +name = "alsa" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43" +dependencies = [ + "alsa-sys", + "bitflags 2.13.2", + "cfg-if", + "libc", +] + +[[package]] +name = "alsa-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "arrayvec" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47a64a0fd06e123e9e3cf3ad01432af17dcab8185e8023edcf184fe696f9675d" + +[[package]] +name = "ash" +version = "0.38.0+1.3.281" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" +dependencies = [ + "libloading", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bindgen" +version = "0.72.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "bitflags 2.13.2", + "cexpr", + "clang-sys", + "itertools", + "proc-macro2", + "quote", + "regex", + "rustc-hash 2.1.3", + "shlex 1.3.0", + "syn 2.0.119", +] + +[[package]] +name = "bit-set" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" + +[[package]] +name = "bit_field" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb2907cc03d08cdb1c6724ad0670ce67c4a71e1c45a6d7635224011714cfc4b1" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2", +] + +[[package]] +name = "bstr" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a680398c10c7bc0488067c4612226ea905a85f607134b69f3068d505d58c4214" +dependencies = [ + "memchr", + "serde_core", +] + +[[package]] +name = "bumpalo" +version = "3.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + +[[package]] +name = "bytes" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c" + +[[package]] +name = "cc" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95e45cf2980b2d467be49a9ed942c9179b701063a7ca3d037de7ee9bd67f8d66" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex 2.0.1", +] + +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "clang-sys" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "combine" +version = "4.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + +[[package]] +name = "core_maths" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" +dependencies = [ + "libm", +] + +[[package]] +name = "coreaudio-rs" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" +dependencies = [ + "bitflags 1.3.2", + "core-foundation-sys", + "coreaudio-sys", +] + +[[package]] +name = "coreaudio-sys" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9b4739a805a62757a83e5654fa3faabec0442666b263bb2287d5a8185bfd953" +dependencies = [ + "bindgen", +] + +[[package]] +name = "cpal" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" +dependencies = [ + "alsa", + "core-foundation-sys", + "coreaudio-rs", + "dasp_sample", + "jni", + "js-sys", + "libc", + "mach2", + "ndk", + "ndk-context", + "oboe", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows 0.54.0", +] + +[[package]] +name = "crc32fast" +version = "1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd9ae8fcb3ea71b0b26338b4ffb13006bb175de8fd07921089a906ce7e5e6945" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "dasp_sample" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + +[[package]] +name = "dispatch2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" +dependencies = [ + "bitflags 2.13.2", + "objc2", +] + +[[package]] +name = "dlib" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a" +dependencies = [ + "libloading", +] + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "encoding_rs" +version = "0.8.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] + +[[package]] +name = "engine" +version = "0.1.0" +dependencies = [ + "bytemuck", + "cc", + "cpal", + "exr", + "fontdb", + "image", + "model", + "png", + "pollster", + "rustybuzz", + "symphonia", + "web-time", + "wgpu", + "zeno", +] + +[[package]] +name = "env_home" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "errno" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "exr" +version = "1.74.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb29d0be702adf92c645d9b2f93472906ba83d400e59f98adb3770ce5c18c2f6" +dependencies = [ + "bit_field", + "half", + "lebe", + "miniz_oxide 0.8.9", + "multiversion", + "rayon-core", + "smallvec", + "zune-inflate", +] + +[[package]] +name = "extended" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365" + +[[package]] +name = "fax" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a" + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e44f110d1777dc6559a51e7d45083945ded4f1bf3305494350f693b6d20b9c8" + +[[package]] +name = "fission-web" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "engine", + "js-sys", + "model", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu", +] + +[[package]] +name = "flate2" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "crc32fast", + "miniz_oxide 0.9.1", + "zlib-rs", +] + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "fontdb" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "457e789b3d1202543297a350643cf459f836cade38934e7a4cf6a39e7cde2905" +dependencies = [ + "log", + "memmap2", + "slotmap", + "tinyvec", + "ttf-parser", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "glow" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29038e1c483364cc6bb3cf78feee1816002e127c331a1eec55a4d202b9e1adb5" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "gpu-allocator" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51255ea7cfaadb6c5f1528d43e92a82acb2b96c43365989a28b2d44ee38f8795" +dependencies = [ + "ash", + "hashbrown 0.16.1", + "log", + "presser", + "thiserror 2.0.21", + "windows 0.62.2", +] + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", + "zerocopy", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc" +dependencies = [ + "foldhash", +] + +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "exr", + "image-webp", + "moxcms", + "num-traits", + "png", + "tiff", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.2", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys 0.3.1", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "khronos-egl" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" +dependencies = [ + "libc", + "libloading", + "pkg-config", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + +[[package]] +name = "lebe" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litrs" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b614978e47ce529faee66579f2b2fe19c94aa96d910a6a9a8043b2b02d8175" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "lua-src" +version = "547.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edaf29e3517b49b8b746701e5648ccb5785cde1c119062cbabbc5d5cd115e42" +dependencies = [ + "cc", +] + +[[package]] +name = "luajit-src" +version = "210.5.12+a4f56a4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a8e7962a5368d5f264d045a5a255e90f9aa3fc1941ae15a8d2940d42cac671" +dependencies = [ + "cc", + "which", +] + +[[package]] +name = "mach2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "memmap2" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +dependencies = [ + "libc", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mlua" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1f5f8fbebc7db5f671671134b9321c4b9aa9adeafccfd9a8c020ae45c6a35d0" +dependencies = [ + "bstr", + "either", + "mlua-sys", + "num-traits", + "parking_lot", + "rustc-hash 2.1.3", + "rustversion", +] + +[[package]] +name = "mlua-sys" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380c1f7e2099cafcf40e51d3a9f20a346977587aa4d012eae1f043149a728a93" +dependencies = [ + "cc", + "cfg-if", + "lua-src", + "luajit-src", + "pkg-config", +] + +[[package]] +name = "model" +version = "0.1.0" +dependencies = [ + "mlua", +] + +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "multiversion" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb8a68be21d0755f83bfe47e79b896cc732687cf1903f0e50585e8d6ecc53076" +dependencies = [ + "multiversion-macros", + "target-features", +] + +[[package]] +name = "multiversion-macros" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a05e0c3c3e4edaa21d87c645852ed0b0c3663752bcc6ec43353bd6189dce35e1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "target-features", +] + +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + +[[package]] +name = "naga" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd0dd362bf26c0ffdd143df6da66a25d287e196eff482f117771010b207ad163" +dependencies = [ + "arrayvec", + "bit-set", + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "codespan-reporting", + "half", + "hashbrown 0.17.2", + "indexmap", + "libm", + "log", + "naga-types", + "num-traits", + "once_cell", + "rustc-hash 1.1.0", + "spirv", + "thiserror 2.0.21", + "unicode-ident", +] + +[[package]] +name = "naga-types" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14474170feb673cfb18b3565111a9869797cc1d290fb9ec969c53f5e1e231c6d" +dependencies = [ + "hashbrown 0.17.2", + "indexmap", + "rustc-hash 1.1.0", + "thiserror 2.0.21", +] + +[[package]] +name = "ndk" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" +dependencies = [ + "bitflags 2.13.2", + "jni-sys 0.3.1", + "log", + "ndk-sys 0.5.0+25.2.9519653", + "num_enum", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.5.0+25.2.9519653" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "objc2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" +dependencies = [ + "objc2-encode", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2", +] + +[[package]] +name = "objc2-core-graphics" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" +dependencies = [ + "dispatch2", + "objc2", + "objc2-core-foundation", + "objc2-io-surface", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" +dependencies = [ + "bitflags 2.13.2", + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-surface" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" +dependencies = [ + "bitflags 2.13.2", + "objc2", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-metal" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" +dependencies = [ + "bitflags 2.13.2", + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" +dependencies = [ + "bitflags 2.13.2", + "objc2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation", + "objc2-metal", +] + +[[package]] +name = "oboe" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" +dependencies = [ + "jni", + "ndk", + "ndk-context", + "num-derive", + "num-traits", + "oboe-sys", +] + +[[package]] +name = "oboe-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" +dependencies = [ + "cc", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "ordered-float" +version = "5.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f59006ce1e204c30956638535b74d317bca99477b9356dfaec54c37f6f600ab" +dependencies = [ + "num-traits", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c938015719552d665fd0553b90d96cd7ff58e83e4c061ca99e6bb78865a72752" + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "png" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" +dependencies = [ + "bitflags 2.13.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "pollster" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" + +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "presser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "profiling" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "range-alloc" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08" + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "raw-window-metal" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40d213455a5f1dc59214213c7330e074ddf8114c9a42411eb890c767357ce135" +dependencies = [ + "objc2", + "objc2-core-foundation", + "objc2-foundation", + "objc2-quartz-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "regex" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" + +[[package]] +name = "renderdoc-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "rustybuzz" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3c7c96f8a08ee34eff8857b11b49b07d71d1c3f4e88f8a88d4c9e9f90b1702" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "core_maths", + "log", + "smallvec", + "ttf-parser", + "unicode-bidi-mirroring", + "unicode-ccc", + "unicode-properties", + "unicode-script", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "slotmap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.16.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59" + +[[package]] +name = "spirv" +version = "0.4.0+sdk-1.4.341.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9571ea910ebd84c86af4b3ed27f9dbdc6ad06f17c5f96146b2b671e2976744f" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "symphonia" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5773a4c030a19d9bfaa090f49746ff35c75dfddfa700df7a5939d5e076a57039" +dependencies = [ + "lazy_static", + "symphonia-bundle-flac", + "symphonia-bundle-mp3", + "symphonia-codec-aac", + "symphonia-codec-pcm", + "symphonia-core", + "symphonia-format-isomp4", + "symphonia-format-ogg", + "symphonia-format-riff", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-bundle-flac" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c91565e180aea25d9b80a910c546802526ffd0072d0b8974e3ebe59b686c9976" +dependencies = [ + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-bundle-mp3" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4872dd6bb56bf5eac799e3e957aa1981086c3e613b27e0ac23b176054f7c57ed" +dependencies = [ + "lazy_static", + "log", + "symphonia-core", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-codec-aac" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c263845aa86881416849c1729a54c7f55164f8b96111dba59de46849e73a790" +dependencies = [ + "lazy_static", + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-codec-pcm" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e89d716c01541ad3ebe7c91ce4c8d38a7cf266a3f7b2f090b108fb0cb031d95" +dependencies = [ + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-core" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea00cc4f79b7f6bb7ff87eddc065a1066f3a43fe1875979056672c9ef948c2af" +dependencies = [ + "arrayvec", + "bitflags 1.3.2", + "bytemuck", + "lazy_static", + "log", +] + +[[package]] +name = "symphonia-format-isomp4" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243739585d11f81daf8dac8d9f3d18cc7898f6c09a259675fc364b382c30e0a5" +dependencies = [ + "encoding_rs", + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-format-ogg" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b4955c67c1ed3aa8ae8428d04ca8397fbef6a19b2b051e73b5da8b1435639cb" +dependencies = [ + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-format-riff" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2d7c3df0e7d94efb68401d81906eae73c02b40d5ec1a141962c592d0f11a96f" +dependencies = [ + "extended", + "log", + "symphonia-core", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-metadata" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36306ff42b9ffe6e5afc99d49e121e0bd62fe79b9db7b9681d48e29fa19e6b16" +dependencies = [ + "encoding_rs", + "lazy_static", + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-utils-xiph" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27c85ab799a338446b68eec77abf42e1a6f1bb490656e121c6e27bfbab9f16" +dependencies = [ + "symphonia-core", + "symphonia-metadata", +] + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-features" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1bbb9f3c5c463a01705937a24fdabc5047929ac764b2d5b9cf681c1f5041ed5" + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "tiff" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg", +] + +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.21+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88497dab46de5bf343ec66b05c251e48c6213f3e9170c70a70a823f7abe886a4" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.7+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb28d6e049a9766c3bd91a8326e6179f5b132dec87906bb97018ef7a2f3431a" +dependencies = [ + "winnow", +] + +[[package]] +name = "ttf-parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" +dependencies = [ + "core_maths", +] + +[[package]] +name = "unicode-bidi-mirroring" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfa6e8c60bb66d49db113e0125ee8711b7647b5579dc7f5f19c42357ed039fe" + +[[package]] +name = "unicode-ccc" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce61d488bcdc9bc8b5d1772c404828b17fc481c0a582b5581e95fb233aef503e" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993ad287eb20e8ba755312801cfe1413e0f25d604075863acaddca10b04c1833" + +[[package]] +name = "unicode-script" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa04c955db05429d464c74d495c1ee677e1866e783a4c3747f9c0cef7756cabf" + +[[package]] +name = "unicode-width" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42e295b7452c4604982280d8586001fcad9b8b201cac67bca9771e7a7475403" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ef4c5d3d2cdf5c54f4231181768f5510842e350db025faf1f7163b1030ed928" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.10", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wayland-sys" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] + +[[package]] +name = "web-sys" +version = "0.3.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fbddc4a036f00ec4f18c83445bd3115cb306a91da554919a099d9222fe4a7f8" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "weezl" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + +[[package]] +name = "wgpu" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146fc3d654250e6207921a66c87534c621bc886c70df83dcf466c1d66813810e" +dependencies = [ + "arrayvec", + "bitflags 2.13.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "document-features", + "hashbrown 0.17.2", + "js-sys", + "log", + "naga", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "smallvec", + "static_assertions", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu-core", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-core" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad661da2ee99f208c30090b585284b2ab5b8bf2358ddf2d2215592808ec62f1a" +dependencies = [ + "arrayvec", + "bit-set", + "bit-vec", + "bitflags 2.13.2", + "bytemuck", + "cfg_aliases", + "document-features", + "hashbrown 0.17.2", + "indexmap", + "log", + "naga", + "naga-types", + "once_cell", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "rustc-hash 1.1.0", + "smallvec", + "thiserror 2.0.21", + "wgpu-core-deps-apple", + "wgpu-core-deps-emscripten", + "wgpu-core-deps-windows-linux-android", + "wgpu-hal", + "wgpu-naga-bridge", + "wgpu-types", +] + +[[package]] +name = "wgpu-core-deps-apple" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d3f2f24aee039ffe9ef527300daf6b7428c58edeefdaa1700f4fa0fd754df16" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-emscripten" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ccf093bd215ae9dc4f96df293e675513ac1f2569f8293a2911cc34ca3505d1" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1331b08fa2362c5d454eccc4448e6e4f01eccfea569a00e310adbfc4415f2bdc" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-hal" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a57452fe453658e141aafdb09de1028afa498805fab518238ddf372a518813ff" +dependencies = [ + "android_system_properties", + "arrayvec", + "ash", + "bit-set", + "bitflags 2.13.2", + "block2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "glow", + "glutin_wgl_sys", + "gpu-allocator", + "hashbrown 0.17.2", + "js-sys", + "khronos-egl", + "libc", + "libloading", + "log", + "naga", + "naga-types", + "ndk-sys 0.6.0+11769913", + "objc2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation", + "objc2-metal", + "objc2-quartz-core", + "once_cell", + "ordered-float", + "parking_lot", + "portable-atomic", + "portable-atomic-util", + "profiling", + "range-alloc", + "raw-window-handle", + "raw-window-metal", + "renderdoc-sys", + "smallvec", + "static_assertions", + "thiserror 2.0.21", + "wasm-bindgen", + "wayland-sys", + "web-sys", + "wgpu-naga-bridge", + "wgpu-types", + "windows 0.62.2", + "windows-core 0.62.2", + "windows-result 0.4.1", +] + +[[package]] +name = "wgpu-naga-bridge" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44a62ead68aad7cd40ac9e2cd2b8ec64f32dfbad2765f429b9fb74b8b735869f" +dependencies = [ + "naga", + "wgpu-types", +] + +[[package]] +name = "wgpu-types" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9f6ee0bd50f5ab79fb8c25e3f33afb27126f034af4ba5909c7a0967058659e6" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "js-sys", + "log", + "naga-types", + "raw-window-handle", + "static_assertions", + "web-sys", +] + +[[package]] +name = "which" +version = "7.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762" +dependencies = [ + "either", + "env_home", + "rustix", + "winsafe", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +dependencies = [ + "windows-core 0.54.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections", + "windows-core 0.62.2", + "windows-future", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" +dependencies = [ + "windows-core 0.62.2", +] + +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result 0.1.2", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result 0.4.1", + "windows-strings", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core 0.62.2", + "windows-link", + "windows-threading", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core 0.62.2", + "windows-link", +] + +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] + +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + +[[package]] +name = "xml-rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" + +[[package]] +name = "zeno" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6df3dc4292935e51816d896edcd52aa30bc297907c26167fec31e2b0c6a32524" + +[[package]] +name = "zerocopy" +version = "0.8.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cba8a86aee14fc8cc6c208af60854b3d4ab7185a9a369a12c648faa2716ff42a" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f89bca3b96ceb3cfcb4572790402f977442270d252b9a8504ebc258760c55f94" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zlib-rs" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa76918995d776d9dd34d371030be228d021137449771493d56e29f77e4148ac" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zune-core" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1a65ee146f41cb456b005bc898af3ab1495ded4ee61ac3637103f40ccacac18" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] diff --git a/crates/web/Cargo.toml b/crates/web/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..724a96c33bc93e38a0dee5210a23870754801519 --- /dev/null +++ b/crates/web/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "fission-web" +version = "0.1.0" +edition = "2024" +publish = false + +# Standalone workspace: the native workspace never builds this crate. +[workspace] + +[lib] +crate-type = ["cdylib"] + +[dependencies] +engine = { path = "../engine" } +model = { path = "../model" } +console_error_panic_hook = "0.1" +js-sys = "0.3" +serde_json = "1" +wasm-bindgen = "=0.2.128" +wasm-bindgen-futures = "0.4" +web-sys = { version = "0.3", features = ["HtmlCanvasElement"] } +wgpu = "30.0.1" + +[profile.release] +opt-level = "s" +lto = true +codegen-units = 1 diff --git a/crates/web/README.md b/crates/web/README.md new file mode 100644 index 0000000000000000000000000000000000000000..63dcb50eb81116cc6bffac65cc6fbb22f60ead40 --- /dev/null +++ b/crates/web/README.md @@ -0,0 +1,44 @@ +# Fission on the web + +Evaluates Fusion `.comp` files with the native `engine` on WebGPU and presents the chosen node to a canvas. +Standalone crate (`[workspace]` in its own manifest): the native workspace never builds it. + +## Build + +```sh +rustup target add wasm32-unknown-unknown +cargo install wasm-bindgen-cli --version 0.2.128 # must match the `=0.2.128` pin in Cargo.toml +crates/web/build.sh # -> crates/web/dist/{index.html,pkg/} +python3 -m http.server -d crates/web/dist 8080 # any static host works +``` + +`OUT=/tmp/fission-web-dist PROFILE=release crates/web/build.sh` redirects the output. Needs a browser with WebGPU. + +## Use + +- **Demo** loads the built-in `demo.comp` (3D simplex `FastNoise`, `Displace`, `TextPlus`, `Merge`, `Glow`, `ColorCorrector`, animated splines and expressions). +- **Open .comp…**, **Open folder…** or drop a `.comp` / project folder on the page. Images in the folder are registered + with `MediaCache::insert_virtual_bytes`; a `Loader` path (even `C:\shots\plate.0001.png`) resolves to the file sharing + the longest run of trailing path components. Missing media is listed under the node list. +- Transport: Play/Pause (Space), scrubber, ←/→ step. The dropdown, the Flow graph and the node list all pick the viewed node. + +## Native vs. wasm differences + +| Area | wasm32 | +| --- | --- | +| Expressions | pure-Rust Lua-subset evaluator (`model::expr`); no statement bodies or method calls | +| Audio, export, RAM prefetch thread | compiled out | +| Video loaders | unavailable (no ffmpeg / AVFoundation) | +| EXR, fonts | not from virtual files / no system fonts (see below) | + +## Needs changes outside this crate's claim + +The browser cannot render until these land; each is verified by building a patched scratch copy and running it in Chrome (WebGPU, Metal). + +1. **`std::time::Instant::now()` panics on `wasm32-unknown-unknown`.** `engine/src/eval/mod.rs:11` and `eval/dispatch.rs:4` + `use std::time::Instant;` must become `use web_time::Instant;` (`web-time` is already a wasm32 dependency of `engine`; + gate it with `cfg(target_arch = "wasm32")` or add it for all targets, where it re-exports `std`). +2. **No fonts**: `text_engine::database()` only loads system fonts, so `TextPlus` renders empty in the browser. + It needs a hook to register font bytes (`fontdb::Database::load_font_data`). +3. **EXR from virtual files**: `media/exr.rs::decode_exr_rgba` opens a `File`; it needs a bytes entry point. +4. `eval/io.rs::probe_clip_dims` still reads dimensions from the filesystem for missing media (cosmetic). diff --git a/crates/web/build.sh b/crates/web/build.sh new file mode 100755 index 0000000000000000000000000000000000000000..2723db10e728a15b15bbf58a0d412988e5dfe08b --- /dev/null +++ b/crates/web/build.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Builds the browser app into crates/web/dist (override with OUT=...), ready to serve statically. +# needs: rustup target add wasm32-unknown-unknown; wasm-bindgen-cli 0.2.128 (cargo install wasm-bindgen-cli --version 0.2.128) +set -euo pipefail +cd "$(dirname "$0")" +out="${OUT:-dist}" +profile="${PROFILE:-release}" + +cargo build --target wasm32-unknown-unknown --profile "$profile" +rm -rf "$out" && mkdir -p "$out" +wasm-bindgen --target web --no-typescript --out-dir "$out/pkg" "target/wasm32-unknown-unknown/$profile/fission_web.wasm" +cp index.html "$out/" +echo "built $out/ -- serve with: python3 -m http.server -d $out 8080" diff --git a/crates/web/demo.comp b/crates/web/demo.comp new file mode 100644 index 0000000000000000000000000000000000000000..64663ea5d7b5c79f2da3a6116ea700d0f07bf1b5 --- /dev/null +++ b/crates/web/demo.comp @@ -0,0 +1,127 @@ +Composition { + CurrentTime = 0, + RenderRange = { 0, 149 }, + GlobalRange = { 0, 149 }, + Tools = ordered() { + NoiseSeethe = BezierSpline { + SplineColor = { Red = 90, Green = 200, Blue = 255 }, + KeyFrames = { + [0] = { 0, Flags = { Linear = true } }, + [149] = { 14, Flags = { Linear = true } }, + }, + }, + WarpAmount = BezierSpline { + SplineColor = { Red = 255, Green = 120, Blue = 60 }, + KeyFrames = { + [0] = { 0, RH = { 25, 0.1 } }, + [75] = { 0.3, LH = { 50, 0.2 }, RH = { 100, 0.2 } }, + [149] = { 0, LH = { 125, 0.1 } }, + }, + }, + GlowSize = BezierSpline { + SplineColor = { Red = 255, Green = 220, Blue = 120 }, + KeyFrames = { + [0] = { 2, Flags = { Linear = true } }, + [75] = { 12, Flags = { Linear = true } }, + [149] = { 2, Flags = { Linear = true } }, + }, + }, + Noise = FastNoise { + Inputs = { + Width = Input { Value = 960, }, + Height = Input { Value = 540, }, + Detail = Input { Value = 4, }, + XScale = Input { Value = 3, }, + YScale = Input { Value = 3, }, + Seethe = Input { SourceOp = "NoiseSeethe", Source = "Value", }, + Color1Red = Input { Value = 0, }, + Color1Green = Input { Value = 0.04, }, + Color1Blue = Input { Value = 0.22, }, + Color1Alpha = Input { Value = 1, }, + Color2Red = Input { Value = 0.1, }, + Color2Green = Input { Value = 0.9, }, + Color2Blue = Input { Value = 1, }, + Color2Alpha = Input { Value = 1, }, + }, + ViewInfo = OperatorInfo { Pos = { 0, 0 } }, + }, + Warm = FastNoise { + Inputs = { + Width = Input { Value = 960, }, + Height = Input { Value = 540, }, + Detail = Input { Value = 3, }, + XScale = Input { Value = 1.6, }, + YScale = Input { Value = 1.6, }, + Seethe = Input { Value = 3, Expression = "time * 0.15 + floor(time / 5) * 2", }, + Color1Red = Input { Value = 0.3, }, + Color1Green = Input { Value = 0.02, }, + Color1Blue = Input { Value = 0.12, }, + Color1Alpha = Input { Value = 1, }, + Color2Red = Input { Value = 1, }, + Color2Green = Input { Value = 0.62, }, + Color2Blue = Input { Value = 0.2, }, + Color2Alpha = Input { Value = 1, }, + }, + ViewInfo = OperatorInfo { Pos = { 0, 80 } }, + }, + Warp = Displace { + Inputs = { + Type = Input { Value = 1, }, + XRefraction = Input { SourceOp = "WarpAmount", Source = "Value", }, + YRefraction = Input { SourceOp = "WarpAmount", Source = "Value", }, + Input = Input { SourceOp = "Warm", Source = "Output", }, + Foreground = Input { SourceOp = "Noise", Source = "Output", }, + }, + ViewInfo = OperatorInfo { Pos = { 150, 40 } }, + }, + Title = TextPlus { + Inputs = { + Width = Input { Value = 960, }, + Height = Input { Value = 540, }, + StyledText = Input { Value = "FISSION", }, + Font = Input { Value = "Helvetica Neue", }, + Style = Input { Value = "Bold", }, + Size = Input { Value = 0.2, Expression = "0.2 + 0.015 * sin(time * 0.15)", }, + Center = Input { Value = { 0.5, 0.5 }, }, + }, + ViewInfo = OperatorInfo { Pos = { 150, 120 } }, + }, + Mix = Merge { + Inputs = { + Background = Input { SourceOp = "Noise", Source = "Output", }, + Foreground = Input { SourceOp = "Warp", Source = "Output", }, + Blend = Input { Value = 0.6, }, + }, + ViewInfo = OperatorInfo { Pos = { 300, 0 } }, + }, + Merge1 = Merge { + Inputs = { + Background = Input { SourceOp = "Mix", Source = "Output", }, + Foreground = Input { SourceOp = "Title", Source = "Output", }, + }, + ViewInfo = OperatorInfo { Pos = { 300, 80 } }, + }, + Glow1 = Glow { + Inputs = { + Input = Input { SourceOp = "Merge1", Source = "Output", }, + XGlowSize = Input { SourceOp = "GlowSize", Source = "Value", }, + Glow = Input { Value = 0.4, }, + }, + ViewInfo = OperatorInfo { Pos = { 450, 80 } }, + }, + Grade = ColorCorrector { + Inputs = { + Input = Input { SourceOp = "Glow1", Source = "Output", }, + WheelSaturation1 = Input { Value = 1.7, }, + MasterRGBGain = Input { Value = 1, }, + MasterRGBGamma = Input { Value = 1.1, }, + }, + ViewInfo = OperatorInfo { Pos = { 600, 80 } }, + }, + }, + Prefs = { + Comp = { + FrameFormat = { Width = 960, Height = 540, Rate = 30, }, + }, + }, +} diff --git a/crates/web/index.html b/crates/web/index.html new file mode 100644 index 0000000000000000000000000000000000000000..3a441f361e90e676c9cc16714ef09efa3e604fd3 --- /dev/null +++ b/crates/web/index.html @@ -0,0 +1,288 @@ + + + + + +Fission + + + +
+

FISSION

+ + + + + +
+ +
+
+ +
Drop a .comp or a project folder here
+
+
+ + + – + +
+
+ + + + + + diff --git a/crates/web/src/lib.rs b/crates/web/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..36058d7836c06400a31e0000354ebf03888d63fa --- /dev/null +++ b/crates/web/src/lib.rs @@ -0,0 +1,263 @@ +//! Browser entry point: evaluates a Fusion `.comp` with the native engine on WebGPU and presents +//! the chosen node to a ``. All UI lives in `index.html`. +#![cfg(target_arch = "wasm32")] + +use engine::media::MediaCache; +use engine::{DisplaySettings, Engine}; +use model::{Comp, NodeId}; +use serde_json::json; +use std::collections::HashSet; +use wasm_bindgen::prelude::*; + +const DEMO_COMP: &str = include_str!("../demo.comp"); + +struct Viewer { + texture: wgpu::Texture, + bind_group: wgpu::BindGroup, +} + +#[wasm_bindgen] +pub struct Fission { + engine: Engine, + surface: wgpu::Surface<'static>, + surface_format: wgpu::TextureFormat, + present: wgpu::RenderPipeline, + sampler: wgpu::Sampler, + viewer: Option, + comp: Option, + target: Option, + unsupported: Vec, +} + +fn js_err(e: impl std::fmt::Display) -> JsError { + JsError::new(&e.to_string()) +} + +#[wasm_bindgen] +impl Fission { + /// Fails with a readable message when the browser has no WebGPU adapter. + pub async fn create(canvas: web_sys::HtmlCanvasElement) -> Result { + console_error_panic_hook::set_once(); + let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::new_without_display_handle()); + let surface = instance.create_surface(wgpu::SurfaceTarget::Canvas(canvas)).map_err(js_err)?; + let adapter = instance + .request_adapter(&wgpu::RequestAdapterOptions { + compatible_surface: Some(&surface), + ..Default::default() + }) + .await + .map_err(|e| JsError::new(&format!("No WebGPU adapter: {e}")))?; + let mut features = wgpu::Features::empty(); + if adapter.features().contains(wgpu::Features::FLOAT32_FILTERABLE) { + features |= wgpu::Features::FLOAT32_FILTERABLE; + } + let (device, queue) = adapter + .request_device(&wgpu::DeviceDescriptor { + required_features: features, + required_limits: adapter.limits(), + ..Default::default() + }) + .await + .map_err(js_err)?; + + let surface_format = surface + .get_capabilities(&adapter) + .formats + .into_iter() + .find(|f| !f.is_srgb()) + .unwrap_or(wgpu::TextureFormat::Bgra8Unorm); + let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor { + label: Some("present"), + source: wgpu::ShaderSource::Wgsl(include_str!("present.wgsl").into()), + }); + let present = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { + label: Some("present"), + layout: None, + vertex: wgpu::VertexState { + module: &shader, + entry_point: Some("vertex"), + compilation_options: Default::default(), + buffers: &[], + }, + fragment: Some(wgpu::FragmentState { + module: &shader, + entry_point: Some("fragment"), + compilation_options: Default::default(), + targets: &[Some(surface_format.into())], + }), + primitive: Default::default(), + depth_stencil: None, + multisample: Default::default(), + multiview_mask: None, + cache: None, + }); + let sampler = device.create_sampler(&wgpu::SamplerDescriptor { + mag_filter: wgpu::FilterMode::Linear, + min_filter: wgpu::FilterMode::Linear, + ..Default::default() + }); + + Ok(Fission { + engine: Engine::new(device, queue), + surface, + surface_format, + present, + sampler, + viewer: None, + comp: None, + target: None, + unsupported: Vec::new(), + }) + } + + pub fn demo_comp() -> String { + DEMO_COMP.to_owned() + } + + /// Registers a project file (a dropped folder's relative path) that `Loader` clips resolve against. + pub fn add_file(&mut self, path: &str, bytes: &[u8]) { + MediaCache::insert_virtual_bytes(path, bytes); + self.engine.bust_all_caches(); + } + + pub fn clear_files(&mut self) { + MediaCache::clear_virtual_bytes(); + self.engine.bust_all_caches(); + } + + /// Parses `text`, selects its default output and returns [`Self::describe`]. + pub fn load_comp(&mut self, text: &str, name: &str) -> Result { + let mut comp = Comp::from_fusion_str(text).map_err(js_err)?; + comp.name = name.to_owned(); + self.target = comp.default_output_node(); + self.comp = Some(comp); + self.engine.bust_all_caches(); + self.describe() + } + + /// JSON: comp format, frame range, node graph and whether each `Loader` clip resolves. + pub fn describe(&self) -> Result { + let comp = self.comp.as_ref().ok_or_else(|| JsError::new("no comp loaded"))?; + let names: HashSet = comp.node_by_name.keys().cloned().collect(); + let nodes: Vec<_> = comp + .nodes + .iter() + .filter(|n| !n.internal) + .map(|n| { + let from: Vec<_> = n.image_connections(&names).into_iter().map(|(port, src, _)| json!([port, src])).collect(); + let clips: Vec<_> = n + .clips + .iter() + .map(|c| json!({ "file": c.filename, "found": engine::media::resolve_clip_path(c, c.global_start).is_some() })) + .collect(); + json!({ "id": n.id.0, "name": n.name, "kind": n.kind, "pos": n.pos, "bypassed": n.bypassed, "from": from, "clips": clips }) + }) + .collect(); + Ok(json!({ + "name": comp.name, + "width": comp.width, + "height": comp.height, + "fps": comp.fps, + "range": comp.render_range, + "target": self.target.map(|t| t.0), + "nodes": nodes, + }) + .to_string()) + } + + pub fn set_node(&mut self, id: usize) -> Result<(), JsError> { + let comp = self.comp.as_ref().ok_or_else(|| JsError::new("no comp loaded"))?; + if id >= comp.nodes.len() { + return Err(JsError::new("no such node")); + } + self.target = Some(NodeId(id)); + Ok(()) + } + + /// Evaluates the selected node at `frame` into the canvas and returns the CPU-side milliseconds. + pub fn render(&mut self, frame: f64) -> Result { + let (comp, target) = self.comp.as_ref().zip(self.target).ok_or_else(|| JsError::new("no comp loaded"))?; + // Cached by the engine, so `render_into_viewer` below reuses it; the size can change with media or time. + let (tex, _) = self.engine.evaluate(comp, target, frame); + if self.viewer.as_ref().is_none_or(|v| [v.texture.width(), v.texture.height()] != tex.canvas_size) { + self.viewer = Some(make_viewer(self.engine.device(), &self.surface, self.surface_format, &self.present, &self.sampler, tex.canvas_size)); + } + let viewer = self.viewer.as_ref().expect("viewer sized above"); + let stats = self.engine.render_into_viewer(comp, target, frame, &viewer.texture, DisplaySettings::default()); + self.unsupported = stats.unsupported_nodes; + + let frame_tex = match self.surface.get_current_texture() { + wgpu::CurrentSurfaceTexture::Success(t) | wgpu::CurrentSurfaceTexture::Suboptimal(t) => t, + _ => return Ok(stats.eval_ms), + }; + let device = self.engine.device(); + let mut encoder = device.create_command_encoder(&Default::default()); + let view = frame_tex.texture.create_view(&Default::default()); + { + let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + color_attachments: &[Some(wgpu::RenderPassColorAttachment { + view: &view, + depth_slice: None, + resolve_target: None, + ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color::BLACK), store: wgpu::StoreOp::Store }, + })], + ..Default::default() + }); + pass.set_pipeline(&self.present); + pass.set_bind_group(0, &viewer.bind_group, &[]); + pass.draw(0..3, 0..1); + } + self.engine.queue().submit(Some(encoder.finish())); + self.engine.queue().present(frame_tex); + Ok(stats.eval_ms) + } + + /// Kinds the last rendered frame could not evaluate. + pub fn unsupported(&self) -> Vec { + self.unsupported.clone() + } +} + +/// Sizes the canvas and the intermediate viewer texture to the node's logical output. +fn make_viewer( + device: &wgpu::Device, + surface: &wgpu::Surface<'static>, + format: wgpu::TextureFormat, + present: &wgpu::RenderPipeline, + sampler: &wgpu::Sampler, + [width, height]: [u32; 2], +) -> Viewer { + surface.configure( + device, + &wgpu::SurfaceConfiguration { + usage: wgpu::TextureUsages::RENDER_ATTACHMENT, + format, + color_space: wgpu::SurfaceColorSpace::Auto, + width, + height, + present_mode: wgpu::PresentMode::AutoVsync, + desired_maximum_frame_latency: 2, + alpha_mode: wgpu::CompositeAlphaMode::Opaque, + view_formats: vec![], + }, + ); + let texture = device.create_texture(&wgpu::TextureDescriptor { + label: Some("viewer"), + size: wgpu::Extent3d { width, height, depth_or_array_layers: 1 }, + mip_level_count: 1, + sample_count: 1, + dimension: wgpu::TextureDimension::D2, + format: wgpu::TextureFormat::Rgba8Unorm, + usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::STORAGE_BINDING, + view_formats: &[], + }); + let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { + label: Some("present"), + layout: &present.get_bind_group_layout(0), + entries: &[ + wgpu::BindGroupEntry { binding: 0, resource: wgpu::BindingResource::TextureView(&texture.create_view(&Default::default())) }, + wgpu::BindGroupEntry { binding: 1, resource: wgpu::BindingResource::Sampler(sampler) }, + ], + }); + Viewer { texture, bind_group } +} diff --git a/crates/web/src/present.wgsl b/crates/web/src/present.wgsl new file mode 100644 index 0000000000000000000000000000000000000000..0bd82c42ad31a11acb7447d58353a6419c597a00 --- /dev/null +++ b/crates/web/src/present.wgsl @@ -0,0 +1,18 @@ +@group(0) @binding(0) var frame: texture_2d; +@group(0) @binding(1) var frame_sampler: sampler; + +struct Vertex { + @builtin(position) position: vec4, + @location(0) uv: vec2, +} + +@vertex +fn vertex(@builtin(vertex_index) index: u32) -> Vertex { + let corner = vec2(f32((index << 1u) & 2u), f32(index & 2u)); + return Vertex(vec4(corner * 2.0 - 1.0, 0.0, 1.0), vec2(corner.x, 1.0 - corner.y)); +} + +@fragment +fn fragment(v: Vertex) -> @location(0) vec4 { + return textureSample(frame, frame_sampler, v.uv); +}