Fix ISRG compiling on web by adding more web cfgs

This commit is contained in:
Jonathan Kelley 2024-09-17 10:19:57 -07:00
parent 463e67cd12
commit 602c605538
No known key found for this signature in database
GPG key ID: 1FBB50F7EB0A08BE
2 changed files with 13 additions and 6 deletions

View file

@ -1,15 +1,16 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
#[cfg(not(target_arch = "wasm32"))]
use crate::fs_cache::PathMapFn;
use crate::IncrementalRenderer; use crate::IncrementalRenderer;
use crate::memory_cache::InMemoryCache;
use std::{ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::Arc,
time::Duration, time::Duration,
}; };
use super::fs_cache::PathMapFn;
use super::memory_cache::InMemoryCache;
/// A configuration for the incremental renderer. /// A configuration for the incremental renderer.
#[derive(Clone)] #[derive(Clone)]
@ -17,9 +18,11 @@ pub struct IncrementalRendererConfig {
static_dir: PathBuf, static_dir: PathBuf,
memory_cache_limit: usize, memory_cache_limit: usize,
invalidate_after: Option<Duration>, invalidate_after: Option<Duration>,
map_path: Option<PathMapFn>,
clear_cache: bool, clear_cache: bool,
pre_render: bool, pre_render: bool,
#[cfg(not(target_arch = "wasm32"))]
map_path: Option<PathMapFn>,
} }
impl Default for IncrementalRendererConfig { impl Default for IncrementalRendererConfig {
@ -35,9 +38,10 @@ impl IncrementalRendererConfig {
static_dir: PathBuf::from("./static"), static_dir: PathBuf::from("./static"),
memory_cache_limit: 10000, memory_cache_limit: 10000,
invalidate_after: None, invalidate_after: None,
map_path: None,
clear_cache: true, clear_cache: true,
pre_render: false, 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`. /// 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. /// 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<F: Fn(&str) -> PathBuf + Send + Sync + 'static>(mut self, map_path: F) -> Self { pub fn map_path<F: Fn(&str) -> 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 self
} }

View file

@ -108,10 +108,12 @@ impl IncrementalRenderer {
) -> Result<Option<CachedRender<'a>>, IncrementalRendererError> { ) -> Result<Option<CachedRender<'a>>, IncrementalRendererError> {
let Self { let Self {
memory_cache, memory_cache,
#[cfg(not(target_arch = "wasm32"))]
file_system_cache, file_system_cache,
.. ..
} = self; } = self;
#[allow(unused)]
enum FsGetError { enum FsGetError {
NotPresent, NotPresent,
Error(IncrementalRendererError), Error(IncrementalRendererError),