From 602c60553811ed77ebe8de6f8a2b125650e6618b Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 17 Sep 2024 10:19:57 -0700 Subject: [PATCH] Fix ISRG compiling on web by adding more web cfgs --- packages/isrg/src/config.rs | 17 +++++++++++------ packages/isrg/src/lib.rs | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/isrg/src/config.rs b/packages/isrg/src/config.rs index c785265e6..4ce13f01c 100644 --- a/packages/isrg/src/config.rs +++ b/packages/isrg/src/config.rs @@ -1,15 +1,16 @@ #![allow(non_snake_case)] +#[cfg(not(target_arch = "wasm32"))] +use crate::fs_cache::PathMapFn; + use crate::IncrementalRenderer; +use crate::memory_cache::InMemoryCache; use std::{ path::{Path, PathBuf}, - sync::Arc, time::Duration, }; -use super::fs_cache::PathMapFn; -use super::memory_cache::InMemoryCache; /// A configuration for the incremental renderer. #[derive(Clone)] @@ -17,9 +18,11 @@ pub struct IncrementalRendererConfig { static_dir: PathBuf, memory_cache_limit: usize, invalidate_after: Option, - map_path: Option, clear_cache: bool, pre_render: bool, + + #[cfg(not(target_arch = "wasm32"))] + map_path: Option, } impl Default for IncrementalRendererConfig { @@ -35,9 +38,10 @@ impl IncrementalRendererConfig { static_dir: PathBuf::from("./static"), memory_cache_limit: 10000, invalidate_after: None, - map_path: None, clear_cache: true, pre_render: false, + #[cfg(not(target_arch = "wasm32"))] + map_path: None, } } @@ -49,8 +53,9 @@ impl IncrementalRendererConfig { /// Set a mapping from the route to the file path. This will override the default mapping configured with `static_dir`. /// The function should return the path to the folder to store the index.html file in. + #[cfg(not(target_arch = "wasm32"))] pub fn map_path PathBuf + Send + Sync + 'static>(mut self, map_path: F) -> Self { - self.map_path = Some(Arc::new(map_path)); + self.map_path = Some(std::sync::Arc::new(map_path)); self } diff --git a/packages/isrg/src/lib.rs b/packages/isrg/src/lib.rs index b22818c8c..9a3f1fac1 100644 --- a/packages/isrg/src/lib.rs +++ b/packages/isrg/src/lib.rs @@ -108,10 +108,12 @@ impl IncrementalRenderer { ) -> Result>, IncrementalRendererError> { let Self { memory_cache, + #[cfg(not(target_arch = "wasm32"))] file_system_cache, .. } = self; + #[allow(unused)] enum FsGetError { NotPresent, Error(IncrementalRendererError),