From 73ffbee638c03da132aea0e5d600ca5e8144fd8e Mon Sep 17 00:00:00 2001 From: Mica White Date: Fri, 3 Jul 2026 15:33:08 -0400 Subject: Support WASM, kinda --- src/file.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/file.rs') diff --git a/src/file.rs b/src/file.rs index 42fecfa..2963879 100644 --- a/src/file.rs +++ b/src/file.rs @@ -1,4 +1,4 @@ -use std::{ffi::OsStr, path::Path, sync::Arc}; +use std::{ffi::OsStr, path::Path}; use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; @@ -9,7 +9,6 @@ use crate::scene::{Scene, scene_id_by_name}; type FileTask = Task>; pub struct FileManager { - pub wasm_compiler: Arc, active_tasks: FxHashMap, FileTask>, cache: FxHashMap, FileData>, } @@ -87,17 +86,20 @@ impl FileData { impl FileManager { pub fn new() -> Self { Self { - wasm_compiler: Arc::new(wasmi::Engine::default()), active_tasks: FxHashMap::default(), cache: FxHashMap::default(), } } - pub fn load_file(&mut self, path: Box) -> std::io::Result<&FileData> { + pub fn load_file( + &mut self, + path: Box, + wasm_compiler: &wasmi::Engine, + ) -> std::io::Result<&FileData> { let data = compile_data( path.as_ref(), &std::fs::read(path.as_ref()).map(Vec::into_boxed_slice)?, - &self.wasm_compiler.clone(), + wasm_compiler, )?; self.cache.entry(path.clone()).insert_entry(data); Ok(self.cache.get(&path).unwrap()) @@ -120,9 +122,9 @@ impl FileManager { } } - pub fn start_loading_file(&mut self, path: impl AsRef) { + pub fn start_loading_file(&mut self, path: impl AsRef, wasm_compiler: &wasmi::Engine) { let boxed_path = Box::from(path.as_ref()); - let compiler = self.wasm_compiler.clone(); + let compiler = wasm_compiler.clone(); let task = unblock(move || { compile_data( &boxed_path, -- cgit v1.2.3